Reduce `Admin::Reports::Actions` spec db activity (#25465)
parent
602c458ab6
commit
38433ccd0b
|
@ -62,17 +62,10 @@ describe Admin::Reports::ActionsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'common behavior' do
|
shared_examples 'common behavior' do
|
||||||
it 'closes the report' do
|
it 'closes the report and redirects' do
|
||||||
expect { subject }.to change { report.reload.action_taken? }.from(false).to(true)
|
expect { subject }.to mark_report_action_taken.and create_target_account_strike
|
||||||
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 text
|
expect(report.target_account.strikes.last.text).to eq text
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects' do
|
|
||||||
subject
|
|
||||||
expect(response).to redirect_to(admin_reports_path)
|
expect(response).to redirect_to(admin_reports_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,20 +74,21 @@ describe Admin::Reports::ActionsController do
|
||||||
{ report_id: report.id }
|
{ report_id: report.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'closes the report' do
|
it 'closes the report and redirects' do
|
||||||
expect { subject }.to change { report.reload.action_taken? }.from(false).to(true)
|
expect { subject }.to mark_report_action_taken.and create_target_account_strike
|
||||||
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 ''
|
expect(report.target_account.strikes.last.text).to eq ''
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects' do
|
|
||||||
subject
|
|
||||||
expect(response).to redirect_to(admin_reports_path)
|
expect(response).to redirect_to(admin_reports_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mark_report_action_taken
|
||||||
|
change { report.reload.action_taken? }.from(false).to(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_target_account_strike
|
||||||
|
change { report.target_account.strikes.count }.by(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'all action types' do
|
shared_examples 'all action types' do
|
||||||
|
|
Reference in New Issue