about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-06-27 00:04:00 +0200
committerGitHub <noreply@github.com>2017-06-27 00:04:00 +0200
commit42b82206322c73c4a4d7ac29ca9a781ab11e7b1a (patch)
treed27e31942c373cf8c919b512b0d6e45c0809468f /spec
parenta91d968cab5120ca389fcc7d6788cafca85e69e7 (diff)
Fix #1624 - Send e-mail notifications to admins about new reports (#3949)
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/api/v1/reports_controller_spec.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/controllers/api/v1/reports_controller_spec.rb b/spec/controllers/api/v1/reports_controller_spec.rb
index 3df6cdfe7..471ea4e0b 100644
--- a/spec/controllers/api/v1/reports_controller_spec.rb
+++ b/spec/controllers/api/v1/reports_controller_spec.rb
@@ -21,12 +21,21 @@ RSpec.describe Api::V1::ReportsController, type: :controller do
   end
 
   describe 'POST #create' do
-    it 'creates a report' do
-      status = Fabricate(:status)
+    let!(:status) { Fabricate(:status) }
+    let!(:admin)  { Fabricate(:user, admin: true) }
+
+    before do
+      allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil))
       post :create, params: { status_ids: [status.id], account_id: status.account.id, comment: 'reasons' }
+    end
 
+    it 'creates a report' do
       expect(status.reload.account.targeted_reports).not_to be_empty
       expect(response).to have_http_status(:success)
     end
+
+    it 'sends e-mails to admins' do
+      expect(AdminMailer).to have_received(:new_report).with(admin.account, Report)
+    end
   end
 end