skill-assessment-app/test/controllers/quiz_controller/summary_test.rb

53 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2016-09-14 17:05:37 -05:00
# frozen_string_literal: true
require 'test_helper'
class QuizControllerTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
test 'summary should require auth and redirect' do
get summary_path
assert_redirected_to login_path
end
test "should get summary" do
auth_candidate candidates :dawn
get summary_path
assert_response :success
assert assigns(:quiz), '@quiz not present'
end
test "should get summary if complete but not submitted" do
auth_candidate candidates(:dawn)
get summary_url
assert_response :success
end
test "should redirect from summary" do
auth_candidate candidates :roy
get summary_path
assert_redirected_to question_path
end
test "should NOT send mailers on submission" do
auth_candidate candidates(:dawn)
assert_enqueued_jobs 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
auth_candidate candidates(:peggy)
assert_enqueued_jobs 3 do
post post_summary_path
end
assert_redirected_to thankyou_path
end
end