diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-07 13:23:23 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-10 16:04:08 +0100 |
commit | 2988e1fbf50b3c9e803a9358933e3e969e64dcc3 (patch) | |
tree | a131797c706f2dba8081fb96ef61660f9f02510a /spec/workers | |
parent | 4e5897f51ef97d7c3ff6c57f81521f552979a3da (diff) | |
download | gitlab-ce-2988e1fbf50b3c9e803a9358933e3e969e64dcc3.tar.gz |
Migrate CI::Services and CI::WebHooks to Services and WebHooks
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/build_email_worker_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/workers/build_email_worker_spec.rb b/spec/workers/build_email_worker_spec.rb new file mode 100644 index 00000000000..7e379502f99 --- /dev/null +++ b/spec/workers/build_email_worker_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe BuildEmailWorker do + include RepoHelpers + + let(:build) { create(:ci_build) } + let(:user) { create(:user) } + let(:data) { Gitlab::BuildDataBuilder.build(build) } + + subject { BuildEmailWorker.new } + + before do + allow(build).to receive(:execute_hooks).and_return(false) + build.success + end + + describe "#perform" do + it "sends mail" do + subject.perform(build.id, user.email, data.stringify_keys) + + email = ActionMailer::Base.deliveries.last + expect(email.subject).to include('Build success for') + expect(email.to).to eq([user.email]) + end + + it "gracefully handles an input SMTP error" do + ActionMailer::Base.deliveries.clear + allow(Notify).to receive(:build_success_email).and_raise(Net::SMTPFatalError) + + subject.perform(build.id, user.email, data.stringify_keys) + + expect(ActionMailer::Base.deliveries.count).to eq(0) + end + end +end |