skill-assessment-app/test/controllers/quiz_controller_test.rb

29 lines
756 B
Ruby
Raw Normal View History

require 'test_helper'
class QuizControllerTest < ActionDispatch::IntegrationTest
def setup_auth candidate
post validate_candidate_url, params: { test_id: candidate.test_hash }
end
test "should require auth and redirect" do
get summary_path
assert_redirected_to login_path
get question_path
assert_redirected_to login_path
get question_path(questions(:fed1).id)
assert_redirected_to login_path
end
test "should get flash message on bad radio response" do
setup_auth candidates(:martha)
qid = questions(:fed1).id
post post_answer_path, params: { answer: { question_id: qid, radio: nil } }
assert_response :success
assert session[:test_id].present?
2016-08-09 23:17:35 -05:00
assert_equal qid, flash[:error]
end
end