diff options
author | Stan Hu <stanhu@gmail.com> | 2015-08-15 08:21:22 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-08-20 09:18:34 +0300 |
commit | 001c8cd0ee6e70cc96727cc37eedf263b916d24b (patch) | |
tree | f91a371d5e53a237681f810d8246ff738927cb9f /spec/workers/emails_on_push_worker_spec.rb | |
parent | 55fc58bda4a5592f2f8deaecec9526fbe4eecd6f (diff) |
Gracefully handle SMTP user input errors (e.g. incorrect email addresses) to prevent Sidekiq retries
Closes https://github.com/gitlabhq/gitlabhq/issues/9560
Diffstat (limited to 'spec/workers/emails_on_push_worker_spec.rb')
-rw-r--r-- | spec/workers/emails_on_push_worker_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb new file mode 100644 index 00000000000..3600c771075 --- /dev/null +++ b/spec/workers/emails_on_push_worker_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe EmailsOnPushWorker do + include RepoHelpers + + let(:project) { create(:project) } + let(:user) { create(:user) } + let(:data) { Gitlab::PushDataBuilder.build_sample(project, user) } + + subject { EmailsOnPushWorker.new } + + before do + allow(Project).to receive(:find).and_return(project) + end + + describe "#perform" do + it "sends mail" do + subject.perform(project.id, user.email, data.stringify_keys) + + email = ActionMailer::Base.deliveries.last + expect(email.subject).to include('Change some files') + expect(email.to).to eq([user.email]) + end + + it "gracefully handles an input SMTP error" do + ActionMailer::Base.deliveries.clear + allow(Notify).to receive(:repository_push_email).and_raise(Net::SMTPFatalError) + + subject.perform(project.id, user.email, data.stringify_keys) + + expect(ActionMailer::Base.deliveries.count).to eq(0) + end + end +end |