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)
70 lines
1.9 KiB
Ruby
70 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
require 'test_helper'
|
|
|
|
module Admin
|
|
class QuizControllerTest < ActionDispatch::IntegrationTest
|
|
def setup
|
|
post admin_auth_url, params: { auth:
|
|
{ email: 'alan.admin@mailinator.com', password: 'password' } }
|
|
end
|
|
|
|
test "should get index" do
|
|
get admin_quizzes_url
|
|
assert_response :success
|
|
assert assigns :quizzes
|
|
end
|
|
|
|
test "should get new" do
|
|
get admin_new_quiz_url
|
|
assert_response :success
|
|
assert assigns :quiz
|
|
end
|
|
|
|
test "should fail create" do
|
|
assert_difference("Quiz.count", 0) do
|
|
post admin_create_quiz_url, params: { quiz: { dept: nil } }
|
|
end
|
|
assert :success
|
|
assert_match(/failed/i, session[:flash].values.join)
|
|
end
|
|
|
|
test "should post create" do
|
|
assert_difference("Quiz.count", 1) do
|
|
post admin_create_quiz_url, params: { quiz:
|
|
{ name: 'PDW Mobile team screening', unit: 'PDW', dept: 'MBL' } }
|
|
end
|
|
assert_redirected_to admin_quizzes_url
|
|
end
|
|
|
|
test "should get view" do
|
|
quiz = quizzes :fed
|
|
get admin_quiz_url quiz.to_i
|
|
assert_response :success
|
|
assert_select 'p', quiz.dept
|
|
end
|
|
|
|
test "should get edit" do
|
|
quiz = quizzes :fed
|
|
get admin_edit_quiz_url quiz.to_i
|
|
assert_response :success
|
|
assert_select "[value=?]", quiz.dept
|
|
end
|
|
|
|
test "should post update quiz" do
|
|
quiz = quizzes(:fed)
|
|
post admin_update_quiz_url(quiz.to_i), params: { quiz: { dept: 'new', unit: 'another' } }
|
|
assert_redirected_to admin_quiz_path(quiz.to_i)
|
|
|
|
get admin_quiz_path quiz.to_i
|
|
assert_select 'p', 'another'
|
|
end
|
|
|
|
test "should fail to update quiz" do
|
|
quiz = quizzes(:fed)
|
|
post admin_update_quiz_url(quiz.to_i), params: { quiz: { dept: nil } }
|
|
assert :success
|
|
assert_match(/failed/i, session[:flash].values.join)
|
|
end
|
|
end
|
|
end
|