diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-13 20:10:58 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-09-13 20:10:58 +0300 |
commit | 9d9c2d314c10347da4a0929db429c2c2bc24a64d (patch) | |
tree | 1c6950d4fe35cdacd90a4e7828ab2b04fef60b37 /spec/services/ci | |
parent | 4ad63c29bb64bbb29598c6eef3b38e8b07c8d9e8 (diff) |
Fix pipeline emails and add tests
Diffstat (limited to 'spec/services/ci')
-rw-r--r-- | spec/services/ci/send_pipeline_notification_service_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/services/ci/send_pipeline_notification_service_spec.rb b/spec/services/ci/send_pipeline_notification_service_spec.rb new file mode 100644 index 00000000000..ba588ed8ef5 --- /dev/null +++ b/spec/services/ci/send_pipeline_notification_service_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Ci::SendPipelineNotificationService, services: true do + let(:user) { create(:user) } + let(:pipeline) { create(:ci_pipeline, user: user, status: status) } + subject{ described_class.new(pipeline) } + + describe '#execute' do + shared_examples 'sending emails' do + it 'sends an email to pipeline user' do + perform_enqueued_jobs do + subject.execute + end + + email = ActionMailer::Base.deliveries.last + expect(email.subject).to include(email_subject) + expect(email.to).to eq([user.email]) + end + end + + context 'with success pipeline' do + let(:status) { 'success' } + let(:email_subject) { 'Pipeline succeeded for' } + + it_behaves_like 'sending emails' + end + + context 'with failed pipeline' do + let(:status) { 'failed' } + let(:email_subject) { 'Pipeline failed for' } + + it_behaves_like 'sending emails' + end + end +end |