displays welcome back when test has started

This commit is contained in:
Mark Moser 2016-08-02 18:30:15 -05:00
parent 1a97bb16fa
commit a3eab2b27a
4 changed files with 32 additions and 0 deletions

View File

@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
def current_candidate def current_candidate
@current_candidate ||= Candidate.find_by(test_hash: session[:test_id]) if session[:test_id] @current_candidate ||= Candidate.find_by(test_hash: session[:test_id]) if session[:test_id]
end end
helper_method :current_candidate
private private

View File

@ -11,6 +11,7 @@ class CandidateController < ApplicationController
end end
def welcome def welcome
render :welcome_back if current_candidate.answers.count > 0
end end
def saved def saved

View File

@ -0,0 +1,16 @@
<% content_for :title, "Skills Assessment" %>
<main class="intro_tpl">
<h1 class="prft-heading">Welcome Back</h1>
<p>Hello <%= current_candidate.name %></p>
<p>
We are ready to pick up where you left off.
</p>
<div class="btn-return">
<%= link_to "Return to Test", question_path, { class: "btn primary-btn" } %>
</div>
</main>

View File

@ -44,6 +44,20 @@ class CandidateControllerTest < ActionDispatch::IntegrationTest
refute flash[:error].present?, "Should not be displaying an error message" refute flash[:error].present?, "Should not be displaying an error message"
end end
test "should display welcome view" do
setup_auth candidates(:martha)
get welcome_path
assert_select '.prft-heading', "Welcome!"
end
test "should display welcome back view" do
setup_auth candidates(:roy)
get welcome_path
assert_select '.prft-heading', "Welcome Back"
end
test "should redirect to thankyou when completed" do test "should redirect to thankyou when completed" do
setup_auth candidates(:richard) setup_auth candidates(:richard)