From b8583f2eae0606f81f25d080c4ec470fdea3a1a0 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 20 May 2025 17:36:06 +0200 Subject: [PATCH] Move shared imageable specs to nested imageable specs file In order to unify all related tests with imageable, we move shared imageable specs and remove that file. --- spec/shared/system/imageable.rb | 32 ------------------------- spec/system/budgets/investments_spec.rb | 5 ---- spec/system/nested_imageable_spec.rb | 13 ++++++++++ spec/system/proposals_spec.rb | 2 -- 4 files changed, 13 insertions(+), 39 deletions(-) delete mode 100644 spec/shared/system/imageable.rb diff --git a/spec/shared/system/imageable.rb b/spec/shared/system/imageable.rb deleted file mode 100644 index 59e08af32..000000000 --- a/spec/shared/system/imageable.rb +++ /dev/null @@ -1,32 +0,0 @@ -shared_examples "imageable" do |imageable_factory_name, imageable_path, imageable_path_arguments| - let!(:administrator) { create(:user) } - let!(:user) { create(:user) } - let!(:imageable_arguments) { {} } - let!(:imageable) { create(imageable_factory_name, author: user) } - - before do - create(:administrator, user: administrator) - - imageable_path_arguments.each do |argument_name, path_to_value| - imageable_arguments.merge!("#{argument_name}": imageable.send(path_to_value)) - end - end - - context "Show" do - scenario "Show descriptive image when exists" do - image = create(:image, imageable: imageable) - - visit send(imageable_path, imageable_arguments) - - expect(page).to have_css("img[alt='#{image.title}'][title='#{image.title}']") - end - - scenario "Show image title when image exists" do - image = create(:image, imageable: imageable) - - visit send(imageable_path, imageable_arguments) - - expect(page).to have_content image.title - end - end -end diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index e4fd1c897..fefe85f19 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -1105,11 +1105,6 @@ describe "Budget Investments" do "budget_investment_path", { budget_id: "budget_id", id: "id" } - it_behaves_like "imageable", - "budget_investment", - "budget_investment_path", - { budget_id: "budget_id", id: "id" } - it_behaves_like "mappable", "budget_investment", "investment", diff --git a/spec/system/nested_imageable_spec.rb b/spec/system/nested_imageable_spec.rb index 936432999..687d17273 100644 --- a/spec/system/nested_imageable_spec.rb +++ b/spec/system/nested_imageable_spec.rb @@ -170,4 +170,17 @@ describe "Nested imageable" do expect(page).to have_css ".image-fields", count: 1, visible: :all end end + + context "Show path" do + let(:factory) { :budget_investment } + let(:path) { polymorphic_path(imageable) } + let!(:image) { create(:image, imageable: imageable) } + + scenario "Show descriptive image and image title when an image exists" do + visit path + + expect(page).to have_css("img[alt='#{image.title}'][title='#{image.title}']") + expect(page).to have_content image.title + end + end end diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index 42c7f566b..7e35b3a1a 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -1293,8 +1293,6 @@ describe "Proposals" do it_behaves_like "followable", "proposal", "proposal_path", { id: "id" } - it_behaves_like "imageable", "proposal", "proposal_path", { id: "id" } - it_behaves_like "mappable", "proposal", "proposal",