admin questions work
This commit is contained in:
@ -1,35 +1,76 @@
|
||||
# require 'test_helper'
|
||||
#
|
||||
# module Admin
|
||||
# class QuestionControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "should get index" do
|
||||
# get admin_questions_url
|
||||
# assert_response :success
|
||||
# end
|
||||
#
|
||||
# test "should get new" do
|
||||
# get admin_new_question_url
|
||||
# assert_response :success
|
||||
# end
|
||||
#
|
||||
# test "should post create" do
|
||||
# post admin_create_question_url
|
||||
# assert_response :success
|
||||
# end
|
||||
#
|
||||
# test "should get view" do
|
||||
# get admin_question_url questions(:fed5).to_i
|
||||
# assert_response :success
|
||||
# end
|
||||
#
|
||||
# test "should get edit" do
|
||||
# get admin_edit_question_url questions(:fed5).to_i
|
||||
# assert_response :success
|
||||
# end
|
||||
#
|
||||
# test "should post update question" do
|
||||
# post admin_update_question_url questions(:fed5).to_i
|
||||
# assert_response :success
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
require 'test_helper'
|
||||
|
||||
module Admin
|
||||
class QuestionControllerTest < 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_questions_url
|
||||
assert_response :success
|
||||
assert assigns :questions
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get admin_new_question_url
|
||||
assert_response :success
|
||||
assert assigns :question
|
||||
end
|
||||
|
||||
test "should fail create" do
|
||||
assert_difference("Question.count", 0) do
|
||||
post admin_create_question_url, params: { question: { question: 'foo bar baz' } }
|
||||
end
|
||||
assert :success
|
||||
assert_match(/failed/i, session[:flash].values.join)
|
||||
end
|
||||
|
||||
test "should fail to create without quiz id" do
|
||||
assert_difference("Question.count", 0) do
|
||||
post admin_create_question_url, params: { question:
|
||||
{ question: 'foo bar baz', category: 'ops', input_type: 'text' } }
|
||||
end
|
||||
assert :success
|
||||
assert_match(/failed/i, session[:flash].values.join)
|
||||
end
|
||||
|
||||
test "should post create" do
|
||||
assert_difference("Question.count", 1) do
|
||||
post admin_create_question_url, params: { question:
|
||||
{ quiz_id: quizzes(:fed).to_i, question: 'foo bar baz', category: 'ops', input_type: 'text' } }
|
||||
end
|
||||
assert_redirected_to admin_questions_url
|
||||
end
|
||||
|
||||
test "should get view" do
|
||||
get admin_question_url questions(:fed5).to_i
|
||||
assert_response :success
|
||||
assert assigns :question
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get admin_edit_question_url questions(:fed5).to_i
|
||||
assert_response :success
|
||||
assert assigns :question
|
||||
end
|
||||
|
||||
test "should post update quiz" do
|
||||
question = questions(:fed9)
|
||||
post admin_update_question_url(question.to_i), params: { question:
|
||||
{ quiz_id: quizzes(:fed).to_i, question: 'foo bar baz', category: 'ops', input_type: 'text' } }
|
||||
assert_redirected_to admin_question_path(question.to_i)
|
||||
|
||||
get admin_question_path question.to_i
|
||||
assert_select 'p', 'foo bar baz'
|
||||
end
|
||||
|
||||
test "should fail to update question" do
|
||||
question = questions(:fed9)
|
||||
post admin_update_question_url(question.to_i), params: { question: { question: nil } }
|
||||
assert :success
|
||||
assert_match(/failed/i, session[:flash].values.join)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user