diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-27 15:06:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-27 15:06:16 +0000 |
commit | 8320f7956d72986f5a7c850874fce4f8b5a8e015 (patch) | |
tree | c761b309cfff422609d47a17ac4d6a732c142f49 /spec/mailers/emails/pipelines_spec.rb | |
parent | 45482d5a2704da7fabe4ccf07f85d9be6e0a791a (diff) | |
download | gitlab-ce-8320f7956d72986f5a7c850874fce4f8b5a8e015.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/mailers/emails/pipelines_spec.rb')
-rw-r--r-- | spec/mailers/emails/pipelines_spec.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/mailers/emails/pipelines_spec.rb b/spec/mailers/emails/pipelines_spec.rb new file mode 100644 index 00000000000..8d4afe9f00f --- /dev/null +++ b/spec/mailers/emails/pipelines_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'email_spec' + +describe Emails::Pipelines do + include EmailSpec::Matchers + + set(:project) { create(:project, :repository) } + + shared_examples_for 'correct pipeline information' do + it 'has a correct information' do + expect(subject) + .to have_subject "#{project.name} | Pipeline ##{pipeline.id} has " \ + "#{status} for #{pipeline.source_ref} | " \ + "#{pipeline.short_sha}".to_s + + expect(subject).to have_body_text pipeline.source_ref + expect(subject).to have_body_text status_text + end + + context 'when pipeline for merge requests' do + let(:pipeline) { merge_request.all_pipelines.first } + + let(:merge_request) do + create(:merge_request, :with_detached_merge_request_pipeline, + source_project: project, + target_project: project) + end + + it 'has a correct information with merge request link' do + expect(subject) + .to have_subject "#{project.name} | Pipeline ##{pipeline.id} has " \ + "#{status} for #{pipeline.source_ref} | " \ + "#{pipeline.short_sha} in !#{merge_request.iid}".to_s + + expect(subject).to have_body_text merge_request.to_reference + expect(subject).to have_body_text pipeline.source_ref + expect(subject).not_to have_body_text pipeline.ref + end + end + end + + describe '#pipeline_success_email' do + subject { Notify.pipeline_success_email(pipeline, pipeline.user.try(:email)) } + + let(:pipeline) { create(:ci_pipeline, project: project, ref: ref, sha: sha) } + let(:ref) { 'master' } + let(:sha) { project.commit(ref).sha } + + it_behaves_like 'correct pipeline information' do + let(:status) { 'succeeded' } + let(:status_text) { 'Your pipeline has passed.' } + end + end + + describe '#pipeline_failed_email' do + subject { Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email)) } + + let(:pipeline) { create(:ci_pipeline, project: project, ref: ref, sha: sha) } + let(:ref) { 'master' } + let(:sha) { project.commit(ref).sha } + + it_behaves_like 'correct pipeline information' do + let(:status) { 'failed' } + let(:status_text) { 'Your pipeline has failed.' } + end + end +end |