Files
grecia/spec/components/admin/budgets/table_actions_component_spec.rb
Javi Martín 02e27e13dc Extract component for budget actions
We can omit passing a parameter to the helper method thanks to that, and
we group related code together.
2020-10-21 13:19:52 +02:00

31 lines
1.0 KiB
Ruby

require "rails_helper"
describe Admin::Budgets::TableActionsComponent, type: :component do
let(:budget) { create(:budget) }
let(:component) { Admin::Budgets::TableActionsComponent.new(budget) }
it "renders links to edit budget, manage investments and edit groups and manage ballots" do
render_inline component
expect(page).to have_css "a", count: 4
expect(page).to have_link "Manage projects", href: /investments/
expect(page).to have_link "Edit headings groups", href: /groups/
expect(page).to have_link "Edit budget", href: /edit/
expect(page).to have_link "Admin ballots"
end
it "renders link to create new poll for budgets without polls" do
render_inline component
expect(page).to have_css "a[href*='polls'][data-method='post']", text: "Admin 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 "Admin ballots", href: /booth_assignments/
end
end