skill-assessment-app/test/controllers/candidate_controller_test.rb
2016-09-14 17:05:37 -05:00

63 lines
1.5 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
class CandidateControllerTest < ActionDispatch::IntegrationTest
test "should get login" do
get login_path
assert_response :success
refute flash[:error].present?, "Should not be displaying an error message"
end
test "should require auth and redirect" do
get saved_path
assert_redirected_to login_path
get thankyou_path
assert_redirected_to login_path
end
test "should auth to welcome" do
auth_candidate candidates(:martha)
assert_redirected_to welcome_path
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
test "should display welcome view" do
auth_candidate candidates(:martha)
get welcome_path
assert_select '.prft-heading', "Welcome!"
end
test "should display welcome back view" do
auth_candidate candidates(:roy)
get welcome_path
assert_select '.prft-heading', "Welcome Back"
end
test "should redirect to thankyou when completed" do
auth_candidate candidates(:richard)
assert_redirected_to thankyou_path
end
test 'should reset session' do
auth_candidate candidates(:dawn)
get thankyou_path
assert :success
assert session[:test_id].nil?
end
end