Fix error messages for question answer images

Since we were creating a new answer in the form, we weren't getting the
errors associated to the answer the administrator was trying to create,
and so we were skipping the test.

Using the answer which contains the information about validation errors
fixes the issue and so we don't have to skip the tests.
This commit is contained in:
Javi Martín
2022-04-04 15:48:31 +02:00
parent fb99d8cb33
commit e637bce3d8
2 changed files with 3 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
<div class="poll-question-form"> <div class="poll-question-form">
<%= form_for(Poll::Question::Answer.new, <%= form_for(@answer,
url: admin_answer_images_path(@answer), url: admin_answer_images_path(@answer),
method: :post) do |f| %> method: :post) do |f| %>
<%= render "shared/errors", resource: @answer %> <%= render "shared/errors", resource: @answer %>

View File

@@ -119,14 +119,10 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
click_link "Add image" click_link "Add image"
click_on submit_button click_on submit_button
if has_many_images
# Pending. Review soon and test
else
within "#nested-image .image" do within "#nested-image .image" do
expect(page).to have_content("can't be blank", count: 2) expect(page).to have_content("can't be blank", count: 2)
end end
end end
end
scenario "Render image preview after sending the form with validation errors", scenario "Render image preview after sending the form with validation errors",
unless: imageable_factory_name == "poll_question_answer" do unless: imageable_factory_name == "poll_question_answer" do