skill-assessment-app/test/controllers/candidate_controller_test.rb
Mark Moser 4bbd93ded1 rubocop noise: fixes FrozenStringLiteralComment
Adding the .ruby-verison file triggered previously un-run cops, specifically:

  This cop is designed to help upgrade to Ruby 3.0. It will add the
  comment `# frozen_string_literal: true` to the top of files to enable
  frozen string literals. Frozen string literals will be default in Ruby
  3.0. The comment will be added below a shebang and encoding comment. The
  frozen string literal comment is only valid in Ruby 2.3+.

More info on rubocop [Automatic-Corrections](https://github.com/bbatsov/rubocop/wiki/Automatic-Corrections)
2016-09-08 10:30:13 -05:00

93 lines
2.2 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
class CandidateControllerTest < ActionDispatch::IntegrationTest
def setup_auth candidate
post validate_candidate_url, params: { test_id: candidate.test_hash }
end
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
setup_auth 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
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)
assert_redirected_to thankyou_path
end
test 'should reset session' do
setup_auth candidates(:dawn)
get thankyou_path
assert :success
assert session[:test_id].nil?
end
test "should get summary if complete but not submitted" do
setup_auth candidates(:dawn)
get summary_url
assert_response :success
end
test "should NOT send mailers on submission" do
setup_auth candidates(:dawn)
assert_difference("ActionMailer::Base.deliveries.size", 0) do
post post_summary_path
end
assert_redirected_to summary_path
assert_match 'must complete', flash[:error]
end
test "should send mailers on submission" do
setup_auth candidates(:peggy)
assert_difference("ActionMailer::Base.deliveries.size", 3) do
post post_summary_path
end
assert_redirected_to thankyou_path
end
end