diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-14 21:57:04 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-17 07:25:20 +0000 |
commit | 811de6ac73ea68ae3361ec49d2094d4f2006f493 (patch) | |
tree | 9150a402a531a9b3b98527e93bf1f97228b8bb38 /spec/models/ci | |
parent | 9c2d40649e0792652c3d41d3c19f2e45c0db5b03 (diff) | |
download | gitlab-ce-811de6ac73ea68ae3361ec49d2094d4f2006f493.tar.gz |
Add test for sending pipeline notifications
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 550a890797e..f564a2d4fdd 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -523,4 +523,58 @@ describe Ci::Pipeline, models: true do expect(pipeline.merge_requests).to be_empty end end + + describe 'notifications when pipeline success or failed' do + before do + ActionMailer::Base.deliveries.clear + + pipeline.enqueue + pipeline.run + end + + shared_examples 'sending a notification' do + it 'sends an email' do + sent_to = ActionMailer::Base.deliveries.flat_map(&:to) + expect(sent_to).to contain_exactly(pipeline.user.email) + end + end + + shared_examples 'not sending any notification' do + it 'does not send any email' do + expect(ActionMailer::Base.deliveries).to be_empty + end + end + + context 'with success pipeline' do + before do + perform_enqueued_jobs do + pipeline.success + end + end + end + + context 'with failed pipeline' do + before do + perform_enqueued_jobs do + pipeline.drop + end + end + end + + context 'with skipped pipeline' do + before do + perform_enqueued_jobs do + pipeline.skip + end + end + end + + context 'with cancelled pipeline' do + before do + perform_enqueued_jobs do + pipeline.cancel + end + end + end + end end |