Files
grecia/spec/components/admin/budgets/table_actions_component_spec.rb
Javi Martín 349dbb74d7 Move phases and actions out of the budget form
Having links in the middle of a form distracts users from the task of
filling in the form, and following a link before submitting the form
will mean whatever has been filled in is lost.

And the budgets form is already very long and hard to fill in. Having
the phases table in the middle of it made it even harder. And, since
we're planning to add the option to manage groups and headings from the
same page, it's better to have a dedicated page for the form.
2021-10-25 18:01:47 +02:00

35 lines
1.2 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 and delete budget, manage investments and edit groups and manage ballots" do
render_inline component
expect(page).to have_link count: 4
expect(page).to have_link "Investment projects", href: /investments/
expect(page).to have_link "Heading groups", href: /groups/
expect(page).to have_link "Edit", href: /#{budget.id}\Z/
expect(page).to have_link "Preview", href: /budgets/
expect(page).to have_button count: 2
expect(page).to have_css "form[action*='budgets']", exact_text: "Delete"
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