diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-03-03 20:50:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 20:50:46 +0100 |
commit | 3f52e717fa22e89a0eaf5f12f0fb9d2b121c7944 (patch) | |
tree | 964f3628ab8fec22fa46f7b717cba834199ca3cd /spec | |
parent | 6b16b77ab0f347e688f009c5a04961142b8dd203 (diff) |
Add tests for moderation actions without custom text (#23184)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin/reports/actions_controller_spec.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/controllers/admin/reports/actions_controller_spec.rb b/spec/controllers/admin/reports/actions_controller_spec.rb index 3e42e4cb1..4c2624a40 100644 --- a/spec/controllers/admin/reports/actions_controller_spec.rb +++ b/spec/controllers/admin/reports/actions_controller_spec.rb @@ -57,6 +57,9 @@ describe Admin::Reports::ActionsController do 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 @@ -72,6 +75,26 @@ describe Admin::Reports::ActionsController do 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 @@ -124,13 +147,13 @@ describe Admin::Reports::ActionsController do 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 |