Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Add tests for moderation actions without custom text (mastodon#23184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored Mar 3, 2023
1 parent 6b16b77 commit 3f52e71
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions spec/controllers/admin/reports/actions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
let!(:media) { Fabricate(:media_attachment, account: target_account, status: statuses[0]) }
let(:report) { Fabricate(:report, target_account: target_account, status_ids: statuses.map(&:id)) }
let(:text) { 'hello' }
let(:common_params) do
{ report_id: report.id, text: text }
end

shared_examples 'common behavior' do
it 'closes the report' do
Expand All @@ -72,6 +75,26 @@
subject
expect(response).to redirect_to(admin_reports_path)
end

context 'when text is unset' do
let(:common_params) do
{ report_id: report.id }
end

it 'closes the report' do
expect { subject }.to change { report.reload.action_taken? }.from(false).to(true)
end

it 'creates a strike with the expected text' do
expect { subject }.to change { report.target_account.strikes.count }.by(1)
expect(report.target_account.strikes.last.text).to eq ''
end

it 'redirects' do
subject
expect(response).to redirect_to(admin_reports_path)
end
end
end

shared_examples 'all action types' do
Expand Down Expand Up @@ -124,13 +147,13 @@
end

context 'action as submit button' do
subject { post :create, params: { report_id: report.id, text: text, action => '' } }
subject { post :create, params: common_params.merge({ action => '' }) }

it_behaves_like 'all action types'
end

context 'action as submit button' do
subject { post :create, params: { report_id: report.id, text: text, moderation_action: action } }
subject { post :create, params: common_params.merge({ moderation_action: action }) }

it_behaves_like 'all action types'
end
Expand Down

0 comments on commit 3f52e71

Please sign in to comment.