Skip to content

Commit

Permalink
Move specs from imageable shared feature spec to proposals and budget…
Browse files Browse the repository at this point in the history
… investments path.
  • Loading branch information
Senen committed Sep 26, 2017
1 parent ceabd16 commit 16692c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
4 changes: 2 additions & 2 deletions spec/features/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
visit budget_investments_path(budget, heading_id: heading.id)

within("#budget_investment_#{investment.id}") do
expect(page).not_to have_css("img")
expect(page).to have_css("div.no-image")
end
within("#budget_investment_#{investment_with_image.id}") do
expect(page).to have_css("img[alt='#{investment_with_image.image.title}']")
Expand Down Expand Up @@ -464,7 +464,7 @@

it_behaves_like "followable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }

it_behaves_like "imageable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }, "budget_investments_path", { "budget_id": "budget_id" }
it_behaves_like "imageable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }

it_behaves_like "nested imageable",
"budget_investment",
Expand Down
18 changes: 17 additions & 1 deletion spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@

expect(page).to have_selector('#proposals .proposal', count: 2)
end

scenario 'Index should show proposal descriptive image only when is defined' do
featured_proposals = create_featured_proposals
proposal = create(:proposal)
proposal_with_image = create(:proposal)
image = create(:image, imageable: proposal_with_image)

visit proposals_path(proposal)

within("#proposal_#{proposal.id}") do
expect(page).to have_css("div.no-image")
end
within("#proposal_#{proposal_with_image.id}") do
expect(page).to have_css("img[alt='#{proposal_with_image.image.title}']")
end
end
end

scenario 'Show' do
Expand Down Expand Up @@ -1274,7 +1290,7 @@

it_behaves_like "followable", "proposal", "proposal_path", { "id": "id" }

it_behaves_like "imageable", "proposal", "proposal_path", { "id": "id" }, "proposals_path", {}
it_behaves_like "imageable", "proposal", "proposal_path", { "id": "id" }

it_behaves_like "nested imageable",
"proposal",
Expand Down
30 changes: 1 addition & 29 deletions spec/shared/features/imageable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
shared_examples "imageable" do |imageable_factory_name, imageable_path, imageable_path_arguments, imageables_path, imageables_path_arguments|
shared_examples "imageable" do |imageable_factory_name, imageable_path, imageable_path_arguments|
include ActionView::Helpers
include ImagesHelper
include ImageablesHelper
Expand All @@ -16,34 +16,6 @@
imageable_path_arguments.each do |argument_name, path_to_value|
imageable_arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end

imageables_path_arguments.each do |argument_name, path_to_value|
imageables_arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end
end

context "Index" do

let!(:featured) { create_list(imageable_factory_name, 3) }
let!(:imageable_with_image) { create(imageable_factory_name) }
let!(:image) { create(:image, imageable: imageable_with_image) }
let!(:imageable_without_image) { create(imageable_factory_name) }

scenario "should show default imageable image not defined" do
visit send(imageables_path, imageables_arguments)

within "##{dom_id(imageable_without_image)}" do
expect(page).to have_css("div.no-image")
end
end

scenario "should show imageable image when exists" do
image = create(:image, imageable: imageable)
visit send(imageables_path, imageables_arguments)

expect(page).to have_css("img[alt='#{image.title}']")
end

end

context "Show" do
Expand Down

0 comments on commit 16692c9

Please sign in to comment.