Convert admin/accounts controller->request specs (#37727)

This commit is contained in:
Matt Jankowski
2026-02-04 05:42:34 -05:00
committed by GitHub
parent a7aa52c7ef
commit 4f99b48e8e
2 changed files with 256 additions and 123 deletions

View File

@@ -109,15 +109,6 @@ RSpec.describe Admin::AccountsController do
context 'when user is admin' do
let(:current_role) { UserRole.find_by(name: 'Admin') }
context 'when target user is admin' do
let(:target_role) { UserRole.find_by(name: 'Admin') }
it 'fails to memorialize account' do
expect(subject).to have_http_status 403
expect(account.reload).to_not be_memorial
end
end
context 'when target user is not admin' do
let(:target_role) { UserRole.find_by(name: 'Moderator') }
@@ -127,28 +118,6 @@ RSpec.describe Admin::AccountsController do
end
end
end
context 'when user is not admin' do
let(:current_role) { UserRole.find_by(name: 'Moderator') }
context 'when target user is admin' do
let(:target_role) { UserRole.find_by(name: 'Admin') }
it 'fails to memorialize account' do
expect(subject).to have_http_status 403
expect(account.reload).to_not be_memorial
end
end
context 'when target user is not admin' do
let(:target_role) { UserRole.find_by(name: 'Moderator') }
it 'fails to memorialize account' do
expect(subject).to have_http_status 403
expect(account.reload).to_not be_memorial
end
end
end
end
describe 'POST #enable' do
@@ -166,15 +135,6 @@ RSpec.describe Admin::AccountsController do
expect(user.reload).to_not be_disabled
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to enable account' do
expect(subject).to have_http_status 403
expect(user.reload).to be_disabled
end
end
end
describe 'POST #approve' do
@@ -204,15 +164,6 @@ RSpec.describe Admin::AccountsController do
)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to approve account' do
expect(subject).to have_http_status 403
expect(user.reload).to_not be_approved
end
end
end
describe 'POST #reject' do
@@ -241,15 +192,6 @@ RSpec.describe Admin::AccountsController do
)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to reject account' do
expect(subject).to have_http_status 403
expect(user.reload).to_not be_approved
end
end
end
describe 'POST #redownload' do
@@ -270,14 +212,6 @@ RSpec.describe Admin::AccountsController do
expect(subject).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to redownload' do
expect(subject).to have_http_status 403
end
end
end
describe 'POST #remove_avatar' do
@@ -293,14 +227,6 @@ RSpec.describe Admin::AccountsController do
expect(subject).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to remove avatar' do
expect(subject).to have_http_status 403
end
end
end
describe 'POST #unblock_email' do
@@ -322,15 +248,6 @@ RSpec.describe Admin::AccountsController do
expect(response).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to remove avatar' do
subject
expect(response).to have_http_status 403
end
end
end
describe 'POST #unsensitive' do
@@ -349,16 +266,6 @@ RSpec.describe Admin::AccountsController do
expect(response).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to change account' do
subject
expect(response).to have_http_status 403
end
end
end
describe 'POST #unsilence' do
@@ -377,16 +284,6 @@ RSpec.describe Admin::AccountsController do
expect(response).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to change account' do
subject
expect(response).to have_http_status 403
end
end
end
describe 'POST #unsuspend' do
@@ -409,16 +306,6 @@ RSpec.describe Admin::AccountsController do
expect(response).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to change account' do
subject
expect(response).to have_http_status 403
end
end
end
describe 'POST #destroy' do
@@ -445,16 +332,6 @@ RSpec.describe Admin::AccountsController do
expect(response).to redirect_to admin_account_path(account.id)
end
end
context 'when user is not admin' do
let(:role) { UserRole.everyone }
it 'fails to change account' do
subject
expect(response).to have_http_status 403
end
end
end
private