correct error mesages for all question types
This commit is contained in:
parent
4d71ac7166
commit
235b4314a4
@ -1,6 +1,5 @@
|
|||||||
<% answer_string = answer.try(:answer) || answer %>
|
<% answer_string = answer.try(:answer) || answer %>
|
||||||
<%= form.collection_radio_buttons(:answer, question.input_options, :to_s, :to_s, {}, {class: ""}) do | option | %>
|
<%= form.collection_radio_buttons(:answer, question.input_options, :to_s, :to_s, {}, {class: ""}) do | option | %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
option_id = "#{question.question_id}#{sanitize_to_id(option.value)}"
|
option_id = "#{question.question_id}#{sanitize_to_id(option.value)}"
|
||||||
checked = answer_string == option.value ? 'checked' : ''
|
checked = answer_string == option.value ? 'checked' : ''
|
||||||
|
@ -7,19 +7,19 @@ class QuestionErrorTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
# text
|
# text
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed1).id } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed1).id } }
|
||||||
assert_select 'h2', questions(:fed1).question
|
assert_select 'h1', questions(:fed1).question
|
||||||
assert_select '.error', /an answer/
|
assert_select '.error', /an answer/
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed1).id, answer: "fooBarBaz" } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed1).id, answer: "fooBarBaz" } }
|
||||||
|
|
||||||
# checkbox
|
# checkbox
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed2).id } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed2).id } }
|
||||||
assert_select 'h2', questions(:fed2).question
|
assert_select 'h1', questions(:fed2).question
|
||||||
assert_select '.error', /an answer/
|
assert_select '.error', /an answer/
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed2).id, answer: "fooBarBaz" } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed2).id, answer: "fooBarBaz" } }
|
||||||
|
|
||||||
# live_code
|
# live_code
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed3).id } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed3).id } }
|
||||||
assert_select 'h2', questions(:fed3).question
|
assert_select 'h1', questions(:fed3).question
|
||||||
assert_select '.error', /comments or code/
|
assert_select '.error', /comments or code/
|
||||||
post post_answer_path, params: { answer: {
|
post post_answer_path, params: { answer: {
|
||||||
question_id: questions(:fed3).id, answer_hash: { html: "fooBarBaz" }
|
question_id: questions(:fed3).id, answer_hash: { html: "fooBarBaz" }
|
||||||
@ -30,7 +30,7 @@ class QuestionErrorTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
# radio
|
# radio
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed5).id } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed5).id } }
|
||||||
assert_select 'h2', questions(:fed5).question
|
assert_select 'h1', questions(:fed5).question
|
||||||
assert_select '.error', /an answer/
|
assert_select '.error', /an answer/
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed5).id, answer: "fooBarBaz" } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed5).id, answer: "fooBarBaz" } }
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class QuestionErrorTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
# radio_other
|
# radio_other
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed8).id } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed8).id } }
|
||||||
assert_select 'h2', questions(:fed8).question
|
assert_select 'h1', questions(:fed8).question
|
||||||
assert_select '.error', /an answer/
|
assert_select '.error', /an answer/
|
||||||
post post_answer_path, params: { answer: {
|
post post_answer_path, params: { answer: {
|
||||||
question_id: questions(:fed8).id, answer_hash: { options: "fooBarBaz" }
|
question_id: questions(:fed8).id, answer_hash: { options: "fooBarBaz" }
|
||||||
@ -52,7 +52,7 @@ class QuestionErrorTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
# checkbox_other
|
# checkbox_other
|
||||||
post post_answer_path, params: { answer: { question_id: questions(:fed9).id } }
|
post post_answer_path, params: { answer: { question_id: questions(:fed9).id } }
|
||||||
assert_select 'h2', questions(:fed9).question
|
assert_select 'h1', questions(:fed9).question
|
||||||
assert_select '.error', /an answer/
|
assert_select '.error', /an answer/
|
||||||
post post_answer_path, params: { answer: {
|
post post_answer_path, params: { answer: {
|
||||||
question_id: questions(:fed9).id, answer_hash: { options: "fooBarBaz" }
|
question_id: questions(:fed9).id, answer_hash: { options: "fooBarBaz" }
|
||||||
|
Loading…
Reference in New Issue
Block a user