split login/welcome and added direct link welcome
This commit is contained in:
parent
7bdb86f89f
commit
737fd10636
@ -30,6 +30,6 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def authorize_candidate
|
def authorize_candidate
|
||||||
redirect_to welcome_path unless current_candidate
|
redirect_to login_path unless current_candidate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
class CandidateController < ApplicationController
|
class CandidateController < ApplicationController
|
||||||
before_action :authorize_candidate, except: [:welcome, :validate, :live_coder]
|
before_action :authorize_candidate, except: [:login, :validate, :live_coder]
|
||||||
|
before_action :send_to_oops, only: [:login]
|
||||||
|
|
||||||
|
def login
|
||||||
|
login_candidate
|
||||||
|
redirect_to :thankyou and return if current_candidate && current_candidate.completed?
|
||||||
|
redirect_to :welcome if current_candidate
|
||||||
|
|
||||||
|
flash[:error] = "Sorry, incorrect test id" if params[:test_hash].present?
|
||||||
|
end
|
||||||
|
|
||||||
def welcome
|
def welcome
|
||||||
end
|
end
|
||||||
@ -7,6 +16,9 @@ class CandidateController < ApplicationController
|
|||||||
def saved
|
def saved
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def oops
|
||||||
|
end
|
||||||
|
|
||||||
def thankyou
|
def thankyou
|
||||||
redirect_to root_path if session[:test_id].nil?
|
redirect_to root_path if session[:test_id].nil?
|
||||||
reset_session
|
reset_session
|
||||||
@ -52,11 +64,22 @@ class CandidateController < ApplicationController
|
|||||||
|
|
||||||
session[:test_id] = candidate.test_hash
|
session[:test_id] = candidate.test_hash
|
||||||
redirect_to :thankyou and return if candidate.completed?
|
redirect_to :thankyou and return if candidate.completed?
|
||||||
redirect_to :question
|
redirect_to :welcome
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def login_candidate
|
||||||
|
candidate = Candidate.find_by(test_hash: params['test_id'])
|
||||||
|
return false if candidate.nil?
|
||||||
|
|
||||||
|
session[:test_id] = candidate.test_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_to_oops
|
||||||
|
redirect_to oops_path if current_candidate
|
||||||
|
end
|
||||||
|
|
||||||
def prep_question qid
|
def prep_question qid
|
||||||
@question = current_candidate.fetch_question(qid)
|
@question = current_candidate.fetch_question(qid)
|
||||||
end
|
end
|
||||||
|
20
app/views/candidate/login.html.erb
Normal file
20
app/views/candidate/login.html.erb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<% content_for :title, "Skills Assessment" %>
|
||||||
|
|
||||||
|
<main class="intro_tpl">
|
||||||
|
<h1 class="prft-heading">Let's Get Started</h1>
|
||||||
|
<p>
|
||||||
|
Hey there! Give us your test id, and we'll get you started.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<%= form_tag(validate_candidate_path) do %>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="userid">What's your Test ID?</label>
|
||||||
|
<input type="text" id="test_id" name="test_id" required/>
|
||||||
|
|
||||||
|
<% if flash[:error].present? %>
|
||||||
|
<div class="error"><%= flash[:error] %></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
<% end %>
|
||||||
|
</main>
|
9
app/views/candidate/oops.html.erb
Normal file
9
app/views/candidate/oops.html.erb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<main class="intro_tpl">
|
||||||
|
<h1 class="prft-heading">Oops!</h1>
|
||||||
|
<p>
|
||||||
|
Looks like you hit the browser's Back button. You can't go backwards in the test,
|
||||||
|
but you'll have a chance at the end to review your answers and make changes.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a href="<%= question_path %>"><button>Continue Test</button></a>
|
||||||
|
</main>
|
@ -1,21 +1,7 @@
|
|||||||
<% content_for :title, "Skills Assessment" %>
|
<% content_for :title, "Skills Assessment" %>
|
||||||
|
|
||||||
<% if session[:test_id].present? %>
|
<main class="intro_tpl">
|
||||||
|
<h1 class="prft-heading">Welcome!</h1>
|
||||||
<main class="intro_tpl">
|
|
||||||
<h1 class="prft-heading">Oops!</h1>
|
|
||||||
<p>
|
|
||||||
Looks like you hit the browser's Back button. You can't go backwards in the test,
|
|
||||||
but you'll have a chance at the end to review your answers and make changes.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<a href="<%= question_path %>"><button>Continue Test</button></a>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<% else %>
|
|
||||||
|
|
||||||
<main class="intro_tpl">
|
|
||||||
<h1 class="prft-heading">Let's Get Started</h1>
|
|
||||||
<p>
|
<p>
|
||||||
This is a skills assessment test. It's the first step in the process of interviewing
|
This is a skills assessment test. It's the first step in the process of interviewing
|
||||||
for a Front-End Development position with Perficient Digital.
|
for a Front-End Development position with Perficient Digital.
|
||||||
@ -34,17 +20,7 @@
|
|||||||
answers, we will review your assessment and your recruiter will be in touch.
|
answers, we will review your assessment and your recruiter will be in touch.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<%= form_tag(validate_candidate_path) do %>
|
<%= link_to question_path do %>
|
||||||
<div class="form-group">
|
|
||||||
<label for="userid">What's your User ID?</label>
|
|
||||||
<input type="text" id="test_id" name="test_id" required/>
|
|
||||||
|
|
||||||
<% if flash[:error].present? %>
|
|
||||||
<div class="error"><%= flash[:error] %></div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<button type="submit">Begin</button>
|
<button type="submit">Begin</button>
|
||||||
<% end %>
|
<% end %>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<% end %>
|
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
<td style="padding:15px 20px; background-color:#cdcdcd; text-align:center;">
|
<td style="padding:15px 20px; background-color:#cdcdcd; text-align:center;">
|
||||||
<h4>
|
<h4>
|
||||||
Please visit <%= link_to nil, root_url %>
|
Please visit <%= link_to nil, login_url(@candidate.test_hash) %> to get started.
|
||||||
and enter the above Candidate ID to being your test.
|
|
||||||
</h4>
|
</h4>
|
||||||
|
<p>If you would rather, visit <%= link_to nil, root_url %>
|
||||||
|
and enter the above Candidate ID to being your test.</p>
|
||||||
<h5>We will reach back to you once we have evaluated your answers. Good luck!</h5>
|
<h5>We will reach back to you once we have evaluated your answers. Good luck!</h5>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
PERFICIENT DIGITAL - Skills Assessment Test
|
PERFICIENT DIGITAL - Skills Assessment Test
|
||||||
|
|
||||||
Your Candidate ID is <%= @candidate.test_hash %>
|
Please visit <%= login_url(@candidate.test_hash) %> to get started.
|
||||||
|
|
||||||
Please visit <%= root_url %>
|
Or, visit <%= root_url %> and enter your Candidate ID to being your test.
|
||||||
and enter the above Candidate ID to being your test.
|
Your Candidate ID is: <%= @candidate.test_hash %>
|
||||||
|
|
||||||
We will reach back to you once we have evaluated your answers.
|
We will reach back to you once we have evaluated your answers.
|
||||||
|
|
||||||
Good luck!
|
Good luck!
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
post "/validate", to: "candidate#validate", as: :validate_candidate
|
post "/validate", to: "candidate#validate", as: :validate_candidate
|
||||||
|
get "/login(/:test_id)", to: "candidate#login", as: :login
|
||||||
get "/welcome", to: "candidate#welcome", as: :welcome
|
get "/welcome", to: "candidate#welcome", as: :welcome
|
||||||
get "/thankyou", to: "candidate#thankyou", as: :thankyou
|
|
||||||
get "/saved", to: "candidate#saved", as: :saved
|
get "/saved", to: "candidate#saved", as: :saved
|
||||||
|
get "/thankyou", to: "candidate#thankyou", as: :thankyou
|
||||||
|
get "/oops", to: "candidate#oops", as: :oops
|
||||||
|
|
||||||
post "/question(/:answer_id)", to: "candidate#update_answer", as: :post_answer
|
post "/question(/:answer_id)", to: "candidate#update_answer", as: :post_answer
|
||||||
get "/question(/:question_id)", to: "candidate#question", as: :question
|
get "/question(/:question_id)", to: "candidate#question", as: :question
|
||||||
@ -24,7 +26,7 @@ Rails.application.routes.draw do
|
|||||||
get "/recruiter/login", to: "recruiter#login", as: :recruiter_login
|
get "/recruiter/login", to: "recruiter#login", as: :recruiter_login
|
||||||
post "/recruiter/login", to: "recruiter#auth", as: :recruiter_auth
|
post "/recruiter/login", to: "recruiter#auth", as: :recruiter_auth
|
||||||
|
|
||||||
root to: "candidate#welcome"
|
root to: "candidate#login"
|
||||||
|
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
end
|
end
|
||||||
|
@ -6,32 +6,42 @@ class CandidateControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "should get login" do
|
test "should get login" do
|
||||||
get welcome_path
|
get login_path
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
refute flash[:error].present?, "Should not be displaying an error message"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should require auth and redirect" do
|
test "should require auth and redirect" do
|
||||||
get saved_path
|
get saved_path
|
||||||
assert_redirected_to welcome_path
|
assert_redirected_to login_path
|
||||||
|
|
||||||
get thankyou_path
|
get thankyou_path
|
||||||
assert_redirected_to welcome_path
|
assert_redirected_to login_path
|
||||||
|
|
||||||
get summary_path
|
get summary_path
|
||||||
assert_redirected_to welcome_path
|
assert_redirected_to login_path
|
||||||
|
|
||||||
get question_path
|
get question_path
|
||||||
assert_redirected_to welcome_path
|
assert_redirected_to login_path
|
||||||
|
|
||||||
get question_path(questions(:fed1).id)
|
get question_path(questions(:fed1).id)
|
||||||
assert_redirected_to welcome_path
|
assert_redirected_to login_path
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should auth to question" do
|
test "should auth to welcome" do
|
||||||
setup_auth candidates(:martha)
|
setup_auth candidates(:martha)
|
||||||
|
|
||||||
assert_redirected_to question_path
|
assert_redirected_to welcome_path
|
||||||
assert session[:test_id].present?
|
assert session[:test_id].present?
|
||||||
|
refute flash[:error].present?, "Should not be displaying an error message"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should auth directly to welcome" do
|
||||||
|
get login_path(candidates(:martha).test_hash)
|
||||||
|
|
||||||
|
assert_redirected_to welcome_path
|
||||||
|
assert session[:test_id].present?
|
||||||
|
refute flash[:error].present?, "Should not be displaying an error message"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should redirect to thankyou when completed" do
|
test "should redirect to thankyou when completed" do
|
||||||
|
Loading…
Reference in New Issue
Block a user