diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-08-02 18:13:27 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-08-02 19:40:10 +0300 |
commit | f097e4dbcd26a0d122776b72ca4370890a0a3f76 (patch) | |
tree | d8529785410ea37dc0e546966373ddf522ead26c /spec/workers/email_receiver_worker_spec.rb | |
parent | 8ec089f3324ca6e181b575560c636c93bde6b52d (diff) |
Don't send rejection mails for all auto-generated mails
Also make it easier to have mailer helper
Diffstat (limited to 'spec/workers/email_receiver_worker_spec.rb')
-rw-r--r-- | spec/workers/email_receiver_worker_spec.rb | 26 |
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 |