From 33b6fa3a02c3851f1753812e4de4fd502ea39a3e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 11 Apr 2018 18:18:09 +0200 Subject: [PATCH] Refactor Investment csv download with filters test There's no need to check again headers in this scenario, previous one already does it. Correctly naming variables, as well as using explicit expectations is a good idea. Last but not least, expectations where reversed but by luck or lack of attention where passing. --- spec/features/admin/budget_investments_spec.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index f710c8fcb..3b75e9b92 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -991,22 +991,18 @@ feature 'Admin budget investments' do end scenario "Downloading CSV file with applied filter" do - investment1 = create(:budget_investment, :unfeasible, budget: budget, - title: 'compatible') - investment2 = create(:budget_investment, :finished, budget: budget, - title: 'finished') + unfeasible_investment = create(:budget_investment, :unfeasible, budget: budget, + title: 'Unfeasible one') + finished_investment = create(:budget_investment, :finished, budget: budget, + title: 'Finished Investment') visit admin_budget_budget_investments_path(budget) within('#filter-subnav') { click_link 'Valuation finished' } click_link "Download current selection" - header = page.response_headers['Content-Disposition'] - expect(header).to match(/^attachment/) - expect(header).to match(/filename="budget_investments.csv"$/) - - expect(page).to have_content investment2.title - expect(page).not_to have_content investment1.title + expect(page).to have_content('Finished Investment') + expect(page).not_to have_content('Unfeasible one') end end