From 9d12b694ce2966eee34e74d8660b2186eae2d45c Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Wed, 16 Nov 2016 18:44:18 -0600 Subject: [PATCH] fixed attachment saving bug --- app/controllers/admin/question_controller.rb | 2 +- test/controllers/admin/question_controller_test.rb | 12 ++++++++++++ test/fixtures/candidates.yml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/question_controller.rb b/app/controllers/admin/question_controller.rb index 1dfbb84..d68160b 100644 --- a/app/controllers/admin/question_controller.rb +++ b/app/controllers/admin/question_controller.rb @@ -62,7 +62,7 @@ module Admin def question_params params.require(:question).permit( - :quiz_id, :question, :category, :input_type, :sort, :active, :input_options, + :quiz_id, :question, :category, :attachment, :input_type, :sort, :active, :input_options, multi_choice: [], live_code: [:later, :html, :css, :js, :text] ) end diff --git a/test/controllers/admin/question_controller_test.rb b/test/controllers/admin/question_controller_test.rb index 767eada..71212b0 100644 --- a/test/controllers/admin/question_controller_test.rb +++ b/test/controllers/admin/question_controller_test.rb @@ -67,6 +67,18 @@ module Admin assert_select 'p', 'foo bar baz' end + test "should post attachment" do + question = questions(:fed1) + post admin_update_question_url(question.to_i), params: { question: + { quiz_id: quizzes(:fed).to_i, attachment: 'https://dev.perficientdigital.com/logo.png' } } + assert_redirected_to admin_question_path(question.to_i) + + get admin_question_path question.to_i + assert_select 'img' do + assert_select "[src=?]", "https://dev.perficientdigital.com/logo.png" + end + end + test "should fail to update question" do question = questions(:fed9) post admin_update_question_url(question.to_i), params: { question: { question: nil } } diff --git a/test/fixtures/candidates.yml b/test/fixtures/candidates.yml index c55d18f..a3c07f7 100644 --- a/test/fixtures/candidates.yml +++ b/test/fixtures/candidates.yml @@ -68,4 +68,4 @@ juan: # Juan has chosen "finish later" for live coders quiz: fed completed: false reminded: true - test_hash: <%= CryptSerializer.dump 'qKQo0l4dyol + test_hash: qKQo0l4dyol