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.
This commit is contained in:
taitus
2025-05-20 17:36:06 +02:00
parent 0332cd3a56
commit b8583f2eae
4 changed files with 13 additions and 39 deletions

View File

@@ -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

View File

@@ -1105,11 +1105,6 @@ describe "Budget Investments" do
"budget_investment_path", "budget_investment_path",
{ budget_id: "budget_id", id: "id" } { 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", it_behaves_like "mappable",
"budget_investment", "budget_investment",
"investment", "investment",

View File

@@ -170,4 +170,17 @@ describe "Nested imageable" do
expect(page).to have_css ".image-fields", count: 1, visible: :all expect(page).to have_css ".image-fields", count: 1, visible: :all
end end
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 end

View File

@@ -1293,8 +1293,6 @@ describe "Proposals" do
it_behaves_like "followable", "proposal", "proposal_path", { id: "id" } it_behaves_like "followable", "proposal", "proposal_path", { id: "id" }
it_behaves_like "imageable", "proposal", "proposal_path", { id: "id" }
it_behaves_like "mappable", it_behaves_like "mappable",
"proposal", "proposal",
"proposal", "proposal",