summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-03 12:41:16 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-08-03 12:41:16 +0000
commit27d34789c99510c5005e2db0a57c308e2eca2bba (patch)
treef3ac85e915bb46548c5988e34c7db408a2f802d6 /spec/workers
parent23c502b43404aa70741462da5d57c23196f6088a (diff)
parent86e1f41b83448423a035707a971acc7ee76a0a8d (diff)
downloadgitlab-ce-27d34789c99510c5005e2db0a57c308e2eca2bba.tar.gz
Merge branch '28472-ignore-auto-generated-mails' into 'master'
Don't send rejection mails for all auto-generated mails Closes #28472 See merge request !13254
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/email_receiver_worker_spec.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb
index fe70501eeac..e4e77c667b3 100644
--- a/spec/workers/email_receiver_worker_spec.rb
+++ b/spec/workers/email_receiver_worker_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe EmailReceiverWorker do
+describe EmailReceiverWorker, :mailer do
let(:raw_message) { fixture_file('emails/valid_reply.eml') }
context "when reply by email is enabled" do
@@ -17,12 +17,16 @@ describe EmailReceiverWorker do
context "when an error occurs" do
before do
- allow_any_instance_of(Gitlab::Email::Receiver).to receive(:execute).and_raise(Gitlab::Email::EmptyEmailError)
+ allow_any_instance_of(Gitlab::Email::Receiver).to receive(:execute).and_raise(error)
end
- it "sends out a rejection email" do
- perform_enqueued_jobs do
- described_class.new.perform(raw_message)
+ context 'when the error is Gitlab::Email::EmptyEmailError' do
+ let(:error) { Gitlab::Email::EmptyEmailError }
+
+ it 'sends out a rejection email' do
+ perform_enqueued_jobs do
+ described_class.new.perform(raw_message)
+ end
email = ActionMailer::Base.deliveries.last
expect(email).not_to be_nil
@@ -30,6 +34,18 @@ describe EmailReceiverWorker do
expect(email.subject).to include("Rejected")
end
end
+
+ context 'when the error is Gitlab::Email::AutoGeneratedEmailError' do
+ let(:error) { Gitlab::Email::AutoGeneratedEmailError }
+
+ it 'does not send out any rejection email' do
+ perform_enqueued_jobs do
+ described_class.new.perform(raw_message)
+ end
+
+ should_not_email_anyone
+ end
+ end
end
end