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

64 lines
1.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-07-31 16:34:35 -05:00
require 'test_helper'
class ReviewControllerTest < ActionDispatch::IntegrationTest
test "should get login" do
get review_login_url
assert_response :success
end
test "should require auth or redirect" do
get review_url
assert_redirected_to review_login_path
get review_test_url(candidates(:richard).test_hash)
assert_redirected_to review_login_path
end
test "should auth to index" do
2016-09-14 17:05:37 -05:00
auth_reviewer
2016-09-22 13:30:30 -05:00
assert_redirected_to admin_path
2016-07-31 16:34:35 -05:00
assert session[:user].present?
end
test "should fail auth with flash" do
post review_auth_url, params: { auth:
{ email: 'fed.review@mailinator.com', password: 'bad-password' } }
assert_redirected_to review_login_path
assert flash[:error]
end
test "should get review list" do
2016-09-14 17:05:37 -05:00
auth_reviewer
2016-07-31 16:34:35 -05:00
get review_url
assert_response :success
assert assigns(:candidates), '@candidates not present'
2016-07-31 16:34:35 -05:00
end
test "should get index" do
2016-09-14 17:05:37 -05:00
auth_reviewer
2016-07-31 16:34:35 -05:00
get review_url
assert_response :success
end
test "should get view" do
2016-09-14 17:05:37 -05:00
auth_reviewer
2016-07-31 16:34:35 -05:00
get review_test_url(candidates(:richard).test_hash)
assert_response :success
assert assigns(:candidate), "@candidate not present"
assert assigns(:quiz), "@quiz not present"
assert assigns(:status), "@status not present"
2016-07-31 16:34:35 -05:00
end
test 'should logout and reset session' do
2016-09-14 17:05:37 -05:00
auth_reviewer
get review_logout_path
assert :success
assert session[:user].nil?
end
2016-07-31 16:34:35 -05:00
end