Files
nairobi/spec/components/admin/budgets/actions_component_spec.rb
Javi Martín 1b407b0702 Move budget ballot actions to admin budget page
The buttons to create polls associated with a budget were too prominent,
appearing on the table as if they were as used as the link to manage
investments. Most CONSUL installations don't use physical booths, and
would probably wonder what that button is about.

We're moving it to a more discrete place, at the bottom of the budget
page. This way we can also split the action in two: on budgets not
having a poll, we display the button in a not-so-accessible position (at
the bottom of the page), since this button will only be used once per
budget at most. Once the poll has been created, it means this feature is
going to be used, so we display a link to manage ballots more
prominently at the top of the page. If the budget has finished the final
voting stage without creating a poll, we don't show either the link or
the button because this feature can no longer be used.

We're also adding some texts indicating what this feature is about,
since it's probably one of the least understood features in CONSUL
(probably because the interface is very confusing... but that's a
different story).

Since now from the budget page we can access every feature related to
the budget, we can remove the "preview" action from the budgets index
table, since this feature isn't that useful for budgets once they're
published.

Now the budgets table doesn't take as much space as it used to, although
it's still too wide to be handled properly on devices with a small
screen.
2021-10-25 18:34:19 +02:00

35 lines
1001 B
Ruby

require "rails_helper"
describe Admin::Budgets::ActionsComponent, controller: Admin::BaseController do
before { sign_in(create(:administrator).user) }
let(:budget) { create(:budget) }
let(:component) { Admin::Budgets::ActionsComponent.new(budget) }
describe "Create booths button" do
it "is rendered for budgets without polls" do
render_inline component
expect(page.find("form[action*='polls'][method='post']")).to have_button "Create booths"
end
it "is not rendered for finished budgets without polls" do
budget.update!(phase: "finished")
render_inline component
expect(page).not_to have_css "form[action*='polls']"
expect(page).not_to have_button "Create booths"
end
it "is not rendered for budgets with polls" do
budget.poll = create(:poll, budget: budget)
render_inline component
expect(page).not_to have_css "form[action*='polls']"
expect(page).not_to have_button "Create booths"
end
end
end