Welcome to mirror list, hosted at ThFree Co, Russian Federation.

send_pipeline_notification_service_spec.rb « ci « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 288302cc94f5cc6d38ae5d02ae876c470e60e811 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'spec_helper'

describe Ci::SendPipelineNotificationService, services: true do
  let(:pipeline) do
    create(:ci_pipeline,
           project: project,
           sha: project.commit('master').sha,
           user: user,
           status: status)
  end

  let(:project) { create(:project) }
  let(:user) { create(:user) }

  subject{ described_class.new(pipeline) }

  describe '#execute' do
    before do
      reset_delivered_emails!
    end

    shared_examples 'sending emails' do
      it 'sends an email to pipeline user' do
        perform_enqueued_jobs do
          subject.execute([user.email])
        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 ##{pipeline.id} has succeeded" }

      it_behaves_like 'sending emails'
    end

    context 'with failed pipeline' do
      let(:status) { 'failed' }
      let(:email_subject) { "Pipeline ##{pipeline.id} has failed" }

      it_behaves_like 'sending emails'
    end
  end
end