Merge pull request #5990 from consuldemocracy/imageable-specs
Regroup all tests related with imageable
This commit is contained in:
@@ -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
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user