Files
grecia/spec/components/admin/table_actions_component_spec.rb
Javi Martín 10c095d821 Move table actions partial to a component
This partial was going to get too complex since in some places we've got
different texts, different URLs or different confirmation messages.
While we should probably try to be more consistent and that would make
the partial work in most cases, there'll always be some exceptions, and
using a partial (with, perhaps, some helper methods) will become messy
really quickly.
2020-10-19 18:56:02 +02:00

30 lines
937 B
Ruby

require "rails_helper"
describe Admin::TableActionsComponent, type: :component do
let(:record) { create(:banner) }
it "renders links to edit and destroy a record by default" do
render_inline Admin::TableActionsComponent.new(record)
expect(page).to have_css "a", count: 2
expect(page).to have_css "a[href*='edit']", text: "Edit"
expect(page).to have_css "a[data-method='delete']", text: "Delete"
end
context "actions parameter is passed" do
it "renders a link to edit a record if passed" do
render_inline Admin::TableActionsComponent.new(record, actions: [:edit])
expect(page).to have_link "Edit"
expect(page).not_to have_link "Delete"
end
it "renders a link to destroy a record if passed" do
render_inline Admin::TableActionsComponent.new(record, actions: [:destroy])
expect(page).to have_link "Delete"
expect(page).not_to have_link "Edit"
end
end
end