From 1c55691319b2eb24c6ba152a3c6e967294fc0eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 27 Jul 2021 18:38:59 +0200 Subject: [PATCH] Merge similar edit nested imageable tests This way we save a couple of database insertions and browser requests. --- spec/shared/system/nested_imageable.rb | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index 1560db273..27eeeff3e 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -207,37 +207,24 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p end if path.include? "edit" - scenario "Should show persisted image" do + scenario "show persisted image" do create(:image, imageable: imageable) do_login_for user + visit send(path, arguments) expect(page).to have_css ".image", count: 1 - end - - scenario "Should not show add image button when image already exists" do - create(:image, imageable: imageable) - do_login_for user - visit send(path, arguments) - expect(page).not_to have_css "a#new_image_link" end - scenario "Should remove nested field after remove image" do + scenario "remove nested field after removing the image" do create(:image, imageable: imageable) do_login_for user + visit send(path, arguments) - click_on "Remove image" + click_link "Remove image" expect(page).not_to have_css ".image" - end - - scenario "Should show add image button after remove image" do - create(:image, imageable: imageable) - do_login_for user - visit send(path, arguments) - click_on "Remove image" - expect(page).to have_css "a#new_image_link" end end