summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-08-14 22:21:22 -0700
committerStan Hu <stanhu@gmail.com>2015-08-19 23:18:34 -0700
commit001c8cd0ee6e70cc96727cc37eedf263b916d24b (patch)
treef91a371d5e53a237681f810d8246ff738927cb9f /spec/workers
parent55fc58bda4a5592f2f8deaecec9526fbe4eecd6f (diff)
downloadgitlab-ce-001c8cd0ee6e70cc96727cc37eedf263b916d24b.tar.gz
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')
-rw-r--r--spec/workers/emails_on_push_worker_spec.rb34
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