2016-09-08 10:25:33 -05:00
|
|
|
# frozen_string_literal: true
|
2016-07-31 18:54:12 -05:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class CandidateControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
test "should get login" do
|
2016-08-02 18:02:20 -05:00
|
|
|
get login_path
|
2016-07-31 18:54:12 -05:00
|
|
|
assert_response :success
|
2016-08-02 18:02:20 -05:00
|
|
|
refute flash[:error].present?, "Should not be displaying an error message"
|
2016-07-31 18:54:12 -05:00
|
|
|
end
|
|
|
|
|
2016-08-01 13:10:59 -05:00
|
|
|
test "should require auth and redirect" do
|
2016-07-31 18:54:12 -05:00
|
|
|
get saved_path
|
2016-08-02 18:02:20 -05:00
|
|
|
assert_redirected_to login_path
|
2016-07-31 18:54:12 -05:00
|
|
|
|
|
|
|
get thankyou_path
|
2016-08-02 18:02:20 -05:00
|
|
|
assert_redirected_to login_path
|
2016-07-31 18:54:12 -05:00
|
|
|
end
|
|
|
|
|
2016-08-02 18:02:20 -05:00
|
|
|
test "should auth to welcome" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_candidate candidates(:martha)
|
2016-07-31 18:54:12 -05:00
|
|
|
|
2016-08-02 18:02:20 -05:00
|
|
|
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
|
2016-07-31 18:54:12 -05:00
|
|
|
assert session[:test_id].present?
|
2016-08-02 18:02:20 -05:00
|
|
|
refute flash[:error].present?, "Should not be displaying an error message"
|
2016-07-31 18:54:12 -05:00
|
|
|
end
|
|
|
|
|
2016-08-02 18:30:15 -05:00
|
|
|
test "should display welcome view" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_candidate candidates(:martha)
|
2016-08-02 18:30:15 -05:00
|
|
|
get welcome_path
|
|
|
|
|
2017-03-20 10:57:50 -05:00
|
|
|
assert_select 'h1', "Welcome!"
|
2016-08-02 18:30:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should display welcome back view" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_candidate candidates(:roy)
|
2016-08-02 18:30:15 -05:00
|
|
|
get welcome_path
|
|
|
|
|
2017-03-20 10:57:50 -05:00
|
|
|
assert_select 'h1', "Welcome Back"
|
2016-08-02 18:30:15 -05:00
|
|
|
end
|
|
|
|
|
2016-07-31 18:54:12 -05:00
|
|
|
test "should redirect to thankyou when completed" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_candidate candidates(:richard)
|
2016-07-31 18:54:12 -05:00
|
|
|
|
|
|
|
assert_redirected_to thankyou_path
|
|
|
|
end
|
|
|
|
|
2016-08-16 17:09:40 -05:00
|
|
|
test 'should reset session' do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_candidate candidates(:dawn)
|
2016-08-16 17:09:40 -05:00
|
|
|
get thankyou_path
|
|
|
|
|
|
|
|
assert :success
|
|
|
|
assert session[:test_id].nil?
|
|
|
|
end
|
2016-07-31 18:54:12 -05:00
|
|
|
end
|