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.
33 lines
1.0 KiB
Ruby
33 lines
1.0 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Admin::Budgets::TableActionsComponent, controller: Admin::BaseController do
|
|
let(:budget) { create(:budget) }
|
|
let(:component) { Admin::Budgets::TableActionsComponent.new(budget) }
|
|
|
|
it "renders actions to edit budget, manage investments and manage ballots" do
|
|
render_inline component
|
|
|
|
expect(page).to have_link count: 3
|
|
expect(page).to have_link "Investment projects", href: /investments/
|
|
expect(page).to have_link "Edit", href: /#{budget.id}\Z/
|
|
expect(page).to have_link "Preview", href: /budgets/
|
|
|
|
expect(page).to have_button count: 1
|
|
expect(page).to have_button "Ballots"
|
|
end
|
|
|
|
it "renders button to create new poll for budgets without polls" do
|
|
render_inline component
|
|
|
|
expect(page).to have_css "form[action*='polls'][method='post']", exact_text: "Ballots"
|
|
end
|
|
|
|
it "renders link to manage ballots for budgets with polls" do
|
|
budget.poll = create(:poll, budget: budget)
|
|
|
|
render_inline component
|
|
|
|
expect(page).to have_link "Ballots", href: /booth_assignments/
|
|
end
|
|
end
|