From e637bce3d8e6bbe425f65b060dd4b2848207996f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 4 Apr 2022 15:48:31 +0200 Subject: [PATCH] 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. --- .../admin/poll/questions/answers/images/new.html.erb | 2 +- spec/shared/system/nested_imageable.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/views/admin/poll/questions/answers/images/new.html.erb b/app/views/admin/poll/questions/answers/images/new.html.erb index fa373fbc1..0ba27107b 100644 --- a/app/views/admin/poll/questions/answers/images/new.html.erb +++ b/app/views/admin/poll/questions/answers/images/new.html.erb @@ -1,5 +1,5 @@
- <%= form_for(Poll::Question::Answer.new, + <%= form_for(@answer, url: admin_answer_images_path(@answer), method: :post) do |f| %> <%= render "shared/errors", resource: @answer %> diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index cbe7a48b3..fb83243ba 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -119,12 +119,8 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p click_link "Add image" click_on submit_button - if has_many_images - # Pending. Review soon and test - else - within "#nested-image .image" do - expect(page).to have_content("can't be blank", count: 2) - end + within "#nested-image .image" do + expect(page).to have_content("can't be blank", count: 2) end end