4bbd93ded1
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)
69 lines
1.6 KiB
Ruby
69 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
require 'test_helper'
|
|
|
|
class ReviewControllerTest < ActionDispatch::IntegrationTest
|
|
def setup_auth
|
|
post review_auth_url, params: { auth:
|
|
{ email: 'fed.reviewer@mailinator.com', password: 'password' } }
|
|
end
|
|
|
|
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
|
|
setup_auth
|
|
assert_redirected_to review_path
|
|
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
|
|
setup_auth
|
|
get review_url
|
|
assert_response :success
|
|
assert assigns(:candidates), '@candidates not present'
|
|
end
|
|
|
|
test "should get index" do
|
|
setup_auth
|
|
|
|
get review_url
|
|
assert_response :success
|
|
end
|
|
|
|
test "should get view" do
|
|
setup_auth
|
|
|
|
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"
|
|
end
|
|
|
|
test 'should logout and reset session' do
|
|
setup_auth
|
|
get review_logout_path
|
|
|
|
assert :success
|
|
assert session[:user].nil?
|
|
end
|
|
end
|