Files
growstuff/spec/features/admin/roles_spec.rb
google-labs-jules[bot] 6c7903c2a5 Fix RSpec/ExpectInHook offenses
- Move expectations from `before` hooks to `it` blocks.
- Ensure controller actions are called after expectations are set in controller specs.
- Replace synchronization expectations in hooks with Capybara `find` calls.
- Remove RSpec/ExpectInHook from .rubocop_todo.yml.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>
2026-04-25 18:39:43 +00:00

63 lines
1.6 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe "roles", :js do
include_context 'signed in admin'
let(:role) { create(:role) }
describe "navigating to roles admin with js" do
before do
visit admin_path
within 'nav#site_admin' do
click_link "Roles"
end
end
it { expect(page).to have_current_path admin_roles_path, ignore_query: true }
it { expect(page).to have_link "New role" }
end
describe "adding a role" do
before do
visit admin_roles_path
click_link "New role"
fill_in 'Name', with: 'Discussion'
fill_in 'Description', with: "this is a new role"
click_button 'Save'
end
it { expect(page).to have_current_path admin_roles_path, ignore_query: true }
it { expect(page).to have_content 'Role was successfully created' }
end
describe 'editing role' do
before do
@role = role
visit admin_roles_path
click_link 'Edit', href: edit_admin_role_path(@role)
fill_in 'Description', with: 'Something else'
click_button 'Save'
role.reload
end
it { expect(page).to have_current_path admin_roles_path, ignore_query: true }
it { expect(page).to have_content 'Role was successfully updated' }
it { expect(page).to have_content 'Something else' }
end
describe 'deleting role' do
before do
@role = role
visit admin_roles_path
accept_confirm do
click_link 'Delete', href: admin_role_path(@role)
end
end
it { expect(page).to have_current_path admin_roles_path, ignore_query: true }
it { expect(page).to have_content 'Role was successfully deleted' }
end
end