Avoid error when accessing final votes stats before balloting phase
When accessing the URL `/admin/stats/budget_balloting?budget_id=X' for a budget in a phase prior to the balloting phase, the following error was raised due to the stats where not calculated yet. Instead, we'll now show a flash message. NoMethodError: undefined method `[]' for nil:NilClass ./app/controllers/admin/stats_controller.rb:82
This commit is contained in:
@@ -189,6 +189,21 @@ describe "Stats" do
|
||||
expect(page).to have_content 0
|
||||
end
|
||||
end
|
||||
|
||||
scenario "hide final voting link" do
|
||||
visit admin_stats_path
|
||||
click_link "Participatory Budgets"
|
||||
|
||||
within("#budget_#{@budget.id}") do
|
||||
expect(page).not_to have_link "Final voting"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "show message when accessing final voting stats" do
|
||||
visit budget_balloting_admin_stats_path(budget_id: @budget.id)
|
||||
|
||||
expect(page).to have_content "There isn't any data to show before the balloting phase."
|
||||
end
|
||||
end
|
||||
|
||||
context "Balloting phase" do
|
||||
|
||||
Reference in New Issue
Block a user