Refactor Investment CSV export download scenario
The created investment didn't had all data to correctly assert each column values are correctly exported. The expectations checking if each particular text appears are invalid in this test. The objective is to check that the downloaded file contents are exactly as they should be... not particular parts checked in an independent way as for example "Yes" could appear in two different columns and just looking if the text appears is not a valid assertion.
This commit is contained in:
@@ -954,16 +954,25 @@ feature 'Admin budget investments' do
|
||||
context "Selecting csv" do
|
||||
|
||||
scenario "Downloading CSV file" do
|
||||
investment = create(:budget_investment, :feasible, budget: budget,
|
||||
price: 100)
|
||||
valuator = create(:valuator, user: create(:user, username: 'Rachel',
|
||||
email: 'rachel@val.org'))
|
||||
group = create(:valuator_group, name: "Test name")
|
||||
|
||||
investment.valuator_groups << group
|
||||
|
||||
admin = create(:administrator, user: create(:user, username: 'Gema'))
|
||||
investment.update(administrator_id: admin.id)
|
||||
admin = create(:administrator, user: create(:user, username: 'Admin'))
|
||||
valuator = create(:valuator, user: create(:user, username: 'Valuator'))
|
||||
valuator_group = create(:valuator_group, name: "Valuator Group")
|
||||
budget_group = create(:budget_group, name: "Budget Group", budget: budget)
|
||||
first_budget_heading = create(:budget_heading, group: budget_group, name: "Budget Heading")
|
||||
second_budget_heading = create(:budget_heading, group: budget_group, name: "Other Heading")
|
||||
first_investment = create(:budget_investment, :feasible, :selected, title: "Le Investment",
|
||||
budget: budget, group: budget_group,
|
||||
heading: first_budget_heading,
|
||||
cached_votes_up: 88, price: 99,
|
||||
valuators: [],
|
||||
valuator_groups: [valuator_group],
|
||||
administrator: admin)
|
||||
second_investment = create(:budget_investment, :unfeasible, title: "Alt Investment",
|
||||
budget: budget, group: budget_group,
|
||||
heading: second_budget_heading,
|
||||
cached_votes_up: 66, price: 88,
|
||||
valuators: [valuator],
|
||||
valuator_groups: [])
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
@@ -973,21 +982,12 @@ feature 'Admin budget investments' do
|
||||
expect(header).to match(/^attachment/)
|
||||
expect(header).to match(/filename="budget_investments.csv"$/)
|
||||
|
||||
valuators = investment.valuators.collect(&:description_or_name).join(', ')
|
||||
feasibility_string = "admin.budget_investments.index"\
|
||||
".feasibility.#{investment.feasibility}"
|
||||
price = I18n.t(feasibility_string, price: investment.formatted_price)
|
||||
|
||||
expect(page).to have_content investment.title
|
||||
expect(page).to have_content investment.total_votes.to_s
|
||||
expect(page).to have_content investment.id.to_s
|
||||
expect(page).to have_content investment.heading.name
|
||||
|
||||
expect(page).to have_content investment.administrator.name
|
||||
expect(page).to have_content valuators
|
||||
expect(page).to have_content group.name
|
||||
expect(page).to have_content price
|
||||
expect(page).to have_content I18n.t('shared.no')
|
||||
csv_contents = "ID,Title,Supports,Administrator,Valuator,Valuation Group,Scope of operation,"\
|
||||
"Feasibility,Val. Fin.,Selected\n#{first_investment.id},Le Investment,88,"\
|
||||
"Admin,-,Valuator Group,Budget Heading,Feasible (€99),Yes,Yes\n"\
|
||||
"#{second_investment.id},Alt Investment,66,No admin assigned,Valuator,-,"\
|
||||
"Other Heading,Unfeasible,No,No\n"
|
||||
expect(page.body).to eq(csv_contents)
|
||||
end
|
||||
|
||||
scenario "Downloading CSV file with applied filter" do
|
||||
|
||||
Reference in New Issue
Block a user