diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 4bad95410..23bed5690 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -36,7 +36,7 @@ feature 'Budget Investments' do 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}']") @@ -464,7 +464,7 @@ feature 'Budget Investments' do 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", diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index af9aa0bc7..2c8db068d 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -45,6 +45,22 @@ feature 'Proposals' do 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 @@ -1274,7 +1290,7 @@ feature 'Proposals' do 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", diff --git a/spec/shared/features/imageable.rb b/spec/shared/features/imageable.rb index fafc8cc52..106da9c4e 100644 --- a/spec/shared/features/imageable.rb +++ b/spec/shared/features/imageable.rb @@ -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 @@ -16,34 +16,6 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl 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