Display first image available for milestones

This commit is contained in:
decabeza
2018-09-12 18:36:17 +02:00
parent d698a724ac
commit ba1a6b4cc8
3 changed files with 25 additions and 13 deletions

View File

@@ -61,6 +61,7 @@ feature 'Executions' do
end
context 'Images' do
scenario 'renders milestone image if available' do
milestone1 = create(:budget_investment_milestone, investment: investment1)
create(:image, imageable: milestone1)
@@ -99,15 +100,21 @@ feature 'Executions' do
expect(page).to have_css("img[alt='#{investment4.title}']")
end
scenario "renders last milestone's image if investment has multiple milestones with images associated" do
scenario "renders first milestone's image if investment has multiple milestones with images associated" do
milestone1 = create(:budget_investment_milestone, investment: investment1,
publication_date: 2.weeks.ago)
publication_date: Date.yesterday)
milestone2 = create(:budget_investment_milestone, investment: investment1,
publication_date: Date.yesterday)
create(:image, imageable: milestone1, title: 'First milestone image')
create(:image, imageable: milestone2, title: 'Second milestone image')
milestone3 = create(:budget_investment_milestone, investment: investment1,
publication_date: Date.yesterday)
milestone4 = create(:budget_investment_milestone, investment: investment1,
publication_date: Date.yesterday)
create(:image, imageable: milestone2, title: 'Image for first milestone with image')
create(:image, imageable: milestone3, title: 'Image for second milestone with image')
visit budget_path(budget)
@@ -116,8 +123,8 @@ feature 'Executions' do
expect(page).to have_content(investment1.title)
expect(page).to have_css("img[alt='#{milestone2.image.title}']")
expect(page).not_to have_css("img[alt='#{milestone1.image.title}']")
end
end
context 'Filters' do