Add customizable user roles (#18641)
* Add customizable user roles * Various fixes and improvements * Add migration for old settings and fix tootctl role management
This commit is contained in:
parent
1b4054256f
commit
44b2ee3485
187 changed files with 1945 additions and 1032 deletions
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
|||
RSpec.describe Admin::InstancesController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:current_user) { Fabricate(:user, admin: true) }
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
let!(:account) { Fabricate(:account, domain: 'popular') }
|
||||
let!(:account2) { Fabricate(:account, domain: 'popular') }
|
||||
|
@ -35,11 +35,11 @@ RSpec.describe Admin::InstancesController, type: :controller do
|
|||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: Instance.first.id } }
|
||||
|
||||
let(:current_user) { Fabricate(:user, admin: admin) }
|
||||
let(:current_user) { Fabricate(:user, role: role) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
context 'when user is admin' do
|
||||
let(:admin) { true }
|
||||
let(:role) { UserRole.find_by(name: 'Admin') }
|
||||
|
||||
it 'succeeds in purging instance' do
|
||||
is_expected.to redirect_to admin_instances_path
|
||||
|
@ -47,7 +47,7 @@ RSpec.describe Admin::InstancesController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when user is not admin' do
|
||||
let(:admin) { false }
|
||||
let(:role) { nil }
|
||||
|
||||
it 'fails to purge instance' do
|
||||
is_expected.to have_http_status :forbidden
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue