Merge pull request #2799 from wairbut-m2c/backport-2588-fix_supports_filter

Fix `max_per_heading` filter in Admin budget investments list
This commit is contained in:
Alberto
2018-07-26 14:11:03 +02:00
committed by GitHub
7 changed files with 29 additions and 47 deletions

View File

@@ -371,59 +371,40 @@ feature 'Admin budget investments' do
expect(page).to have_content 'The budget has to stay on phase "Balloting projects", "Reviewing Ballots" or "Finished budget" in order to calculate winners projects'
end
scenario "Limiting by max number of investments per heading", :js do
scenario "Filtering by minimum number of votes", :js do
group_1 = create(:budget_group, budget: budget)
group_2 = create(:budget_group, budget: budget)
parks = create(:budget_heading, group: group_1)
roads = create(:budget_heading, group: group_2)
streets = create(:budget_heading, group: group_2)
[2, 4, 90, 100, 200, 300].each do |n|
create(:budget_investment, heading: parks, cached_votes_up: n, title: "Park with #{n} supports")
end
[21, 31, 51, 81, 91, 101].each do |n|
create(:budget_investment, heading: roads, cached_votes_up: n, title: "Road with #{n} supports")
end
[3, 10, 30, 33, 44, 55].each do |n|
create(:budget_investment, heading: streets, cached_votes_up: n, title: "Street with #{n} supports")
end
create(:budget_investment, heading: parks, cached_votes_up: 40, title: "Park with 40 supports")
create(:budget_investment, heading: parks, cached_votes_up: 99, title: "Park with 99 supports")
create(:budget_investment, heading: roads, cached_votes_up: 100, title: "Road with 100 supports")
create(:budget_investment, heading: roads, cached_votes_up: 199, title: "Road with 199 supports")
create(:budget_investment, heading: streets, cached_votes_up: 200, title: "Street with 200 supports")
create(:budget_investment, heading: streets, cached_votes_up: 300, title: "Street with 300 supports")
visit admin_budget_budget_investments_path(budget)
[2, 4, 90, 100, 200, 300].each do |n|
expect(page).to have_link("Park with #{n} supports")
end
[21, 31, 51, 81, 91, 101].each do |n|
expect(page).to have_link("Road with #{n} supports")
end
[3, 10, 30, 33, 44, 55].each do |n|
expect(page).to have_link("Street with #{n} supports")
end
expect(page).to have_link("Park with 40 supports")
expect(page).to have_link("Park with 99 supports")
expect(page).to have_link("Road with 100 supports")
expect(page).to have_link("Road with 199 supports")
expect(page).to have_link("Street with 200 supports")
expect(page).to have_link("Street with 300 supports")
click_link 'Advanced filters'
fill_in "max_per_heading", with: 5
fill_in "min_total_supports", with: 180
click_button 'Filter'
expect(page).to have_content('There are 15 investments')
expect(page).not_to have_link("Park with 2 supports")
expect(page).not_to have_link("Road with 21 supports")
expect(page).not_to have_link("Street with 3 supports")
[4, 90, 100, 200, 300].each do |n|
expect(page).to have_link("Park with #{n} supports")
end
[31, 51, 81, 91, 101].each do |n|
expect(page).to have_link("Road with #{n} supports")
end
[10, 30, 33, 44, 55].each do |n|
expect(page).to have_link("Street with #{n} supports")
end
expect(page).to have_content('There are 3 investments')
expect(page).to have_link("Road with 199 supports")
expect(page).to have_link("Street with 200 supports")
expect(page).to have_link("Street with 300 supports")
expect(page).not_to have_link("Park with 40 supports")
expect(page).not_to have_link("Park with 99 supports")
expect(page).not_to have_link("Road with 100 supports")
end
scenario "Combination of checkbox with text search", :js do