diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ed68e9d..4aed618 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base def current_candidate @current_candidate ||= Candidate.find_by(test_hash: session[:test_id]) if session[:test_id] end + helper_method :current_candidate private diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb index 6031fc4..f543d96 100644 --- a/app/controllers/candidate_controller.rb +++ b/app/controllers/candidate_controller.rb @@ -11,6 +11,7 @@ class CandidateController < ApplicationController end def welcome + render :welcome_back if current_candidate.answers.count > 0 end def saved diff --git a/app/views/candidate/welcome_back.html.erb b/app/views/candidate/welcome_back.html.erb new file mode 100644 index 0000000..0648c9a --- /dev/null +++ b/app/views/candidate/welcome_back.html.erb @@ -0,0 +1,16 @@ +<% content_for :title, "Skills Assessment" %> + +
+

Welcome Back

+ +

Hello <%= current_candidate.name %>

+ +

+ We are ready to pick up where you left off. +

+ +
+ <%= link_to "Return to Test", question_path, { class: "btn primary-btn" } %> +
+ +
diff --git a/test/controllers/candidate_controller_test.rb b/test/controllers/candidate_controller_test.rb index adba814..74006a6 100644 --- a/test/controllers/candidate_controller_test.rb +++ b/test/controllers/candidate_controller_test.rb @@ -44,6 +44,20 @@ class CandidateControllerTest < ActionDispatch::IntegrationTest refute flash[:error].present?, "Should not be displaying an error message" 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 setup_auth candidates(:richard)