Add information about budget actions
Both the calculate winners and delete actions benefit from some kind of hint. The "calculate winners" hint informs administrators that results won't be publicly available unless the "show results" option is enabled. The delete action was redirecting with an error message when the budget couldn't be deleted; IMHO it's better to disable it and inform administrators why it's disabled. Alternatively we could remove the button completely; however, users might be looking for a way to delete a budget and wouldn't find any hint about it. We're now removing the "Delete" action from the budgets index table, since most of the time it isn't possible to delete a budget and so the action takes up space and we get little gain in return. We could keep the "Delete" icon just for budgets which can be deleted; however, the alignment of the table rows would suffer, making it harder to find the intended action.
This commit is contained in:
@@ -92,22 +92,6 @@ describe "Admin budgets", :admin do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Delete budget from index" do
|
||||
create(:budget, name: "To be deleted")
|
||||
|
||||
visit admin_budgets_path
|
||||
|
||||
within "tr", text: "To be deleted" do
|
||||
message = "Are you sure? This action will delete \"To be deleted\" and can't be undone."
|
||||
|
||||
accept_confirm(message) { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content("Budget deleted successfully")
|
||||
expect(page).to have_content("There are no budgets.")
|
||||
expect(page).not_to have_content "To be deleted"
|
||||
end
|
||||
end
|
||||
|
||||
context "Publish" do
|
||||
@@ -141,18 +125,10 @@ describe "Admin budgets", :admin do
|
||||
|
||||
scenario "Destroy a budget without investments" do
|
||||
visit admin_budget_path(budget)
|
||||
click_button "Delete budget"
|
||||
|
||||
expect(page).to have_content("Budget deleted successfully")
|
||||
expect(page).to have_content("There are no budgets.")
|
||||
end
|
||||
message = "Are you sure? This will delete the budget and all its associated groups and headings. This action cannot be undone."
|
||||
|
||||
scenario "Destroy a budget without investments but with administrators and valuators" do
|
||||
budget.administrators << Administrator.first
|
||||
budget.valuators << create(:valuator)
|
||||
|
||||
visit admin_budget_path(budget)
|
||||
click_button "Delete budget"
|
||||
accept_confirm(message) { click_button "Delete budget" }
|
||||
|
||||
expect(page).to have_content "Budget deleted successfully"
|
||||
expect(page).to have_content "There are no budgets."
|
||||
@@ -162,20 +138,18 @@ describe "Admin budgets", :admin do
|
||||
create(:budget_investment, heading: heading)
|
||||
|
||||
visit admin_budget_path(budget)
|
||||
click_button "Delete budget"
|
||||
|
||||
expect(page).to have_content("You cannot delete a budget that has associated investments")
|
||||
expect(page).to have_content("There is 1 budget")
|
||||
expect(page).to have_button "Delete budget", disabled: true
|
||||
expect(page).to have_content "You cannot delete a budget that has associated investments"
|
||||
end
|
||||
|
||||
scenario "Try to destroy a budget with polls" do
|
||||
create(:poll, budget: budget)
|
||||
|
||||
visit admin_budget_path(budget)
|
||||
click_button "Delete budget"
|
||||
|
||||
expect(page).to have_content("You cannot delete a budget that has an associated poll")
|
||||
expect(page).to have_content("There is 1 budget")
|
||||
expect(page).to have_button "Delete budget", disabled: true
|
||||
expect(page).to have_content "You cannot delete a budget that has an associated poll"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user