gitlab-org--gitlab-foss/spec/services/ci/send_pipeline_notification_...

40 lines
1.0 KiB
Ruby
Raw Normal View History

2016-09-13 17:10:58 +00:00
require 'spec_helper'
describe Ci::SendPipelineNotificationService, services: true do
2016-09-23 11:45:48 +00:00
let(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit('master').sha)
end
let(:project) { create(:project) }
2016-09-13 17:10:58 +00:00
let(:user) { create(:user) }
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([user.email])
2016-09-13 17:10:58 +00:00
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