Skip to content

Commit

Permalink
Fix moderator rights inconsistencies (#26729)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Sep 19, 2023
1 parent 412c3e1 commit 49af3e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
File renamed without changes.
9 changes: 9 additions & 0 deletions app/lib/admin/account_statuses_filter.rb
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Admin::AccountStatusesFilter < AccountStatusesFilter
private

def blocked?
false
end
end
2 changes: 1 addition & 1 deletion app/models/admin/status_batch_action.rb
Expand Up @@ -137,6 +137,6 @@ def report_params
end

def allowed_status_ids
AccountStatusesFilter.new(@report.target_account, current_account).results.with_discarded.where(id: status_ids).pluck(:id)
Admin::AccountStatusesFilter.new(@report.target_account, current_account).results.with_discarded.where(id: status_ids).pluck(:id)
end
end
20 changes: 16 additions & 4 deletions spec/controllers/admin/statuses_controller_spec.rb
Expand Up @@ -40,24 +40,36 @@
end

describe 'POST #batch' do
before do
post :batch, params: { :account_id => account.id, action => '', :admin_status_batch_action => { status_ids: status_ids } }
end
subject { post :batch, params: { :account_id => account.id, action => '', :admin_status_batch_action => { status_ids: status_ids } } }

let(:status_ids) { [media_attached_status.id] }

context 'when action is report' do
shared_examples 'when action is report' do
let(:action) { 'report' }

it 'creates a report' do
subject

report = Report.last
expect(report.target_account_id).to eq account.id
expect(report.status_ids).to eq status_ids
end

it 'redirects to report page' do
subject

expect(response).to redirect_to(admin_report_path(Report.last.id))
end
end

it_behaves_like 'when action is report'

context 'when the moderator is blocked by the author' do
before do
account.block!(user.account)
end

it_behaves_like 'when action is report'
end
end
end

0 comments on commit 49af3e2

Please sign in to comment.