diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-12 13:20:21 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-12 14:01:28 +0100 |
commit | 055ec4dc0ae1fd765ee1e624f307bf2b00fa4c12 (patch) | |
tree | 49abcaca6f1ba49306537285ec2d7b463fdf3e5c /spec/mailers/emails | |
parent | 349adab1425ba97065614e320deb3108d2a99758 (diff) | |
download | gitlab-ce-055ec4dc0ae1fd765ee1e624f307bf2b00fa4c12.tar.gz |
Move build emails specs to separate file
This also extracts shared examples for notification emails to separate
file.
Diffstat (limited to 'spec/mailers/emails')
-rw-r--r-- | spec/mailers/emails/builds_spec.rb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/mailers/emails/builds_spec.rb b/spec/mailers/emails/builds_spec.rb new file mode 100644 index 00000000000..0df89938e97 --- /dev/null +++ b/spec/mailers/emails/builds_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' +require 'email_spec' +require 'mailers/shared/notify' + +describe Notify do + include EmailSpec::Matchers + + include_context 'gitlab email notification' + + describe 'build notification email' do + let(:build) { create(:ci_build) } + let(:project) { build.project } + + shared_examples 'build email' do + it 'contains name of project' do + is_expected.to have_body_text build.project_name + end + + it 'contains link to project' do + is_expected.to have_body_text namespace_project_path(project.namespace, project) + end + end + + shared_examples 'an email with X-GitLab headers containing build details' do + it 'has X-GitLab-Build* headers' do + is_expected.to have_header 'X-GitLab-Build-Id', /#{build.id}/ + is_expected.to have_header 'X-GitLab-Build-Ref', /#{build.ref}/ + end + end + + describe 'build success' do + subject { Notify.build_success_email(build.id, 'wow@example.com') } + before { build.success } + + it_behaves_like 'build email' + it_behaves_like 'an email with X-GitLab headers containing build details' + it_behaves_like 'an email with X-GitLab headers containing project details' + + it 'has header indicating build status' do + is_expected.to have_header 'X-GitLab-Build-Status', 'success' + end + + it 'has the correct subject' do + is_expected.to have_subject /Build success for/ + end + end + + describe 'build fail' do + subject { Notify.build_fail_email(build.id, 'wow@example.com') } + before { build.drop } + + it_behaves_like 'build email' + it_behaves_like 'an email with X-GitLab headers containing build details' + it_behaves_like 'an email with X-GitLab headers containing project details' + + it 'has header indicating build status' do + is_expected.to have_header 'X-GitLab-Build-Status', 'failed' + end + + it 'has the correct subject' do + is_expected.to have_subject /Build failed for/ + end + end + end +end |