adds budget stats for final voting to admin stats

This commit is contained in:
Juanjo Bazán
2017-05-24 14:26:36 +02:00
committed by Javi Martín
parent 5be54b57da
commit 110ee961e3
9 changed files with 209 additions and 70 deletions

View File

@@ -103,91 +103,147 @@ feature "Stats" do
end
describe "Budget investments" do
background do
@budget = create(:budget)
@group_all_city = create(:budget_group, budget: @budget)
@heading_all_city = create(:budget_heading, group: @group_all_city)
end
scenario "Number of supports in investment projects" do
group_2 = create(:budget_group, budget: @budget)
investment1 = create(:budget_investment, heading: create(:budget_heading, group: group_2))
investment2 = create(:budget_investment, heading: @heading_all_city)
1.times { create(:vote, votable: investment1) }
2.times { create(:vote, votable: investment2) }
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{@budget.id}") do
click_link "Supporting phase"
context "Supporting phase" do
background do
@budget = create(:budget)
@group_all_city = create(:budget_group, budget: @budget)
@heading_all_city = create(:budget_heading, group: @group_all_city)
end
expect(page).to have_content "Votes 3"
end
scenario "Number of supports in investment projects" do
group_2 = create(:budget_group, budget: @budget)
investment1 = create(:budget_investment, heading: create(:budget_heading, group: group_2))
investment2 = create(:budget_investment, heading: @heading_all_city)
scenario "Number of users that have voted a investment project" do
user1 = create(:user, :level_two)
user2 = create(:user, :level_two)
user3 = create(:user, :level_two)
1.times { create(:vote, votable: investment1) }
2.times { create(:vote, votable: investment2) }
group_2 = create(:budget_group, budget: @budget)
investment1 = create(:budget_investment, heading: create(:budget_heading, group: group_2))
investment2 = create(:budget_investment, heading: @heading_all_city)
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{@budget.id}") do
click_link "Supporting phase"
end
create(:vote, votable: investment1, voter: user1)
create(:vote, votable: investment1, voter: user2)
create(:vote, votable: investment2, voter: user1)
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{@budget.id}") do
click_link "Supporting phase"
expect(page).to have_content "Votes 3"
end
expect(page).to have_content "Participants 2"
end
scenario "Number of users that have supported an investment project" do
user1 = create(:user, :level_two)
user2 = create(:user, :level_two)
user3 = create(:user, :level_two)
scenario "Number of users that have voted a investment project per geozone" do
budget = create(:budget)
group_2 = create(:budget_group, budget: @budget)
investment1 = create(:budget_investment, heading: create(:budget_heading, group: group_2))
investment2 = create(:budget_investment, heading: @heading_all_city)
group_all_city = create(:budget_group, budget: budget)
group_districts = create(:budget_group, budget: budget)
create(:vote, votable: investment1, voter: user1)
create(:vote, votable: investment1, voter: user2)
create(:vote, votable: investment2, voter: user1)
all_city = create(:budget_heading, group: group_all_city)
carabanchel = create(:budget_heading, group: group_districts)
barajas = create(:budget_heading, group: group_districts)
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{@budget.id}") do
click_link "Supporting phase"
end
all_city_investment = create(:budget_investment, heading: all_city)
carabanchel_investment = create(:budget_investment, heading: carabanchel)
carabanchel_investment = create(:budget_investment, heading: carabanchel)
Budget::Investment.all.each do |investment|
create(:vote, votable: investment)
expect(page).to have_content "Participants 2"
end
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{budget.id}") do
click_link "Supporting phase"
end
scenario "Number of users that have supported investments projects per geozone" do
budget = create(:budget)
within("#budget_heading_#{all_city.id}") do
expect(page).to have_content all_city.name
expect(page).to have_content 1
end
group_all_city = create(:budget_group, budget: budget)
group_districts = create(:budget_group, budget: budget)
within("#budget_heading_#{carabanchel.id}") do
expect(page).to have_content carabanchel.name
expect(page).to have_content 2
end
all_city = create(:budget_heading, group: group_all_city)
carabanchel = create(:budget_heading, group: group_districts)
barajas = create(:budget_heading, group: group_districts)
within("#budget_heading_#{barajas.id}") do
expect(page).to have_content barajas.name
expect(page).to have_content 0
all_city_investment = create(:budget_investment, heading: all_city)
carabanchel_investment = create(:budget_investment, heading: carabanchel)
carabanchel_investment = create(:budget_investment, heading: carabanchel)
Budget::Investment.all.each do |investment|
create(:vote, votable: investment)
end
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{budget.id}") do
click_link "Supporting phase"
end
within("#budget_heading_#{all_city.id}") do
expect(page).to have_content all_city.name
expect(page).to have_content 1
end
within("#budget_heading_#{carabanchel.id}") do
expect(page).to have_content carabanchel.name
expect(page).to have_content 2
end
within("#budget_heading_#{barajas.id}") do
expect(page).to have_content barajas.name
expect(page).to have_content 0
end
end
end
context "Balloting phase" do
scenario "Number of votes in investment projects" do
budget = create(:budget, :balloting)
ballot_1 = create(:budget_ballot, budget: budget)
ballot_2 = create(:budget_ballot, budget: budget)
group_1 = create(:budget_group, budget: budget)
heading_1 = create(:budget_heading, group: group_1)
investment_1 = create(:budget_investment, :feasible, :selected, heading: heading_1)
group_2 = create(:budget_group, budget: budget)
heading_2 = create(:budget_heading, group: group_2)
investment_2 = create(:budget_investment, :feasible, :selected, heading: heading_2)
create(:budget_ballot_line, ballot: ballot_1, investment: investment_1)
create(:budget_ballot_line, ballot: ballot_1, investment: investment_2)
create(:budget_ballot_line, ballot: ballot_2, investment: investment_2)
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{budget.id}") do
click_link "Final voting"
end
expect(page).to have_content "Votes 3"
end
scenario "Number of users that have voted a investment project" do
user_1 = create(:user, :level_two)
user_2 = create(:user, :level_two)
user_3 = create(:user, :level_two)
budget = create(:budget, :balloting)
ballot_1 = create(:budget_ballot, budget: budget, user: user_1)
ballot_2 = create(:budget_ballot, budget: budget, user: user_2)
ballot_3 = create(:budget_ballot, budget: budget, user: user_3)
group = create(:budget_group, budget: budget)
heading = create(:budget_heading, group: group)
investment = create(:budget_investment, :feasible, :selected, heading: heading)
create(:budget_ballot_line, ballot: ballot_1, investment: investment)
create(:budget_ballot_line, ballot: ballot_2, investment: investment)
visit admin_stats_path
click_link "Participatory Budgets"
within("#budget_#{budget.id}") do
click_link "Final voting"
end
expect(page).to have_content "Participants 2"
end
end
end
context "graphs" do