Extract component to add/remove admin/mod/manager

We remove some duplication by doing so.
This commit is contained in:
Javi Martín
2020-07-01 19:01:06 +02:00
parent 02e27e13dc
commit 08c2bfc255
9 changed files with 63 additions and 33 deletions

View File

@@ -0,0 +1,17 @@
require "rails_helper"
describe Admin::Roles::TableActionsComponent, type: :component do
let(:user) { create(:user) }
it "renders link to add the role for new records" do
render_inline Admin::Roles::TableActionsComponent.new(user.build_manager)
expect(page).to have_css "a[data-method='post']", text: "Add"
end
it "renders link to remove the role for existing records" do
render_inline Admin::Roles::TableActionsComponent.new(create(:manager, user: user))
expect(page).to have_css "a[data-method='delete']", text: "Delete"
end
end