diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-09-21 22:46:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 22:46:35 +0200 |
commit | 26c51cfa07952b39802ce6de4c952c6adf56b748 (patch) | |
tree | 76d4ce01bfa2b7dee5a469007f8419fd7f8a7b73 /spec | |
parent | 8cf7006d4efbcfdd4a4ab688db1bcc73a2915a47 (diff) |
Fix various rspec warnings in ReportService tests (#19189)
* Fix various rspec warnings in ReportService tests * Add tests to ReportService
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/report_service_spec.rb | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/spec/services/report_service_spec.rb b/spec/services/report_service_spec.rb index ea68b3344..02bc42ac1 100644 --- a/spec/services/report_service_spec.rb +++ b/spec/services/report_service_spec.rb @@ -42,13 +42,44 @@ RSpec.describe ReportService, type: :service do end it 'creates a report' do - is_expected.to change { target_account.targeted_reports.count }.from(0).to(1) + expect { subject.call }.to change { target_account.targeted_reports.count }.from(0).to(1) + end + + it 'attaches the DM to the report' do + subject.call + expect(target_account.targeted_reports.pluck(:status_ids)).to eq [[status.id]] end end context 'when it is not addressed to the reporter' do it 'errors out' do - is_expected.to raise_error + expect { subject.call }.to raise_error(ActiveRecord::RecordNotFound) + end + end + + context 'when the reporter is remote' do + let(:source_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/1') } + + context 'when it is addressed to the reporter' do + before do + status.mentions.create(account: source_account) + end + + it 'creates a report' do + expect { subject.call }.to change { target_account.targeted_reports.count }.from(0).to(1) + end + + it 'attaches the DM to the report' do + subject.call + expect(target_account.targeted_reports.pluck(:status_ids)).to eq [[status.id]] + end + end + + context 'when it is not addressed to the reporter' do + it 'does not add the DM to the report' do + subject.call + expect(target_account.targeted_reports.pluck(:status_ids)).to eq [[]] + end end end end @@ -67,7 +98,7 @@ RSpec.describe ReportService, type: :service do end it 'does not send an e-mail' do - is_expected.to_not change(ActionMailer::Base.deliveries, :count).from(0) + expect { subject.call }.to_not change(ActionMailer::Base.deliveries, :count).from(0) end end end |