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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 14:31:16 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 14:31:16 +0300
commit905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch)
tree756d138db422392c00471ab06acdff92c5a9b69c /spec/mailers
parent50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff)
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/emails/pipelines_spec.rb69
-rw-r--r--spec/mailers/emails/releases_spec.rb52
-rw-r--r--spec/mailers/notify_spec.rb8
3 files changed, 125 insertions, 4 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
diff --git a/spec/mailers/emails/releases_spec.rb b/spec/mailers/emails/releases_spec.rb
new file mode 100644
index 00000000000..19f404db2a6
--- /dev/null
+++ b/spec/mailers/emails/releases_spec.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'email_spec'
+
+describe Emails::Releases do
+ include EmailSpec::Matchers
+ include_context 'gitlab email notification'
+
+ describe '#new_release_email' do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let(:release) { create(:release, project: project) }
+
+ subject { Notify.new_release_email(user.id, release) }
+
+ it_behaves_like 'an email sent from GitLab'
+
+ context 'when the release has a name' do
+ it 'shows the correct subject' do
+ expected_subject = "#{release.project.name} | New release: #{release.name} - #{release.tag}"
+ is_expected.to have_subject(expected_subject)
+ end
+ end
+
+ context 'when the release does not have a name' do
+ it 'shows the correct subject' do
+ release.name = nil
+ expected_subject = "#{release.project.name} | New release: #{release.tag}"
+
+ is_expected.to have_subject(expected_subject)
+ end
+ end
+
+ it 'contains a message with the new release tag' do
+ message = "A new Release #{release.tag} for #{release.project.name} was published."
+ is_expected.to have_body_text(message)
+ end
+
+ it 'contains the release assets' do
+ is_expected.to have_body_text('Assets:')
+ release.sources do |source|
+ is_expected.to have_body_text("Download #{source.format}")
+ end
+ end
+
+ it 'contains the release notes' do
+ is_expected.to have_body_text('Release notes:')
+ is_expected.to have_body_text(release.description)
+ end
+ end
+end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 56fa26d5f23..1991bac0229 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -714,7 +714,7 @@ describe Notify do
describe 'project access requested' do
let(:project) do
- create(:project, :public, :access_requestable) do |project|
+ create(:project, :public) do |project|
project.add_maintainer(project.owner)
end
end
@@ -743,7 +743,7 @@ describe Notify do
end
describe 'project access denied' do
- let(:project) { create(:project, :public, :access_requestable) }
+ let(:project) { create(:project, :public) }
let(:project_member) do
project.request_access(user)
project.requesters.find_by(user_id: user.id)
@@ -765,7 +765,7 @@ describe Notify do
describe 'project access changed' do
let(:owner) { create(:user, name: "Chang O'Keefe") }
- let(:project) { create(:project, :public, :access_requestable, namespace: owner.namespace) }
+ let(:project) { create(:project, :public, namespace: owner.namespace) }
let(:project_member) { create(:project_member, project: project, user: user) }
subject { described_class.member_access_granted_email('project', project_member.id) }
@@ -1167,7 +1167,7 @@ describe Notify do
context 'for a group' do
describe 'group access requested' do
- let(:group) { create(:group, :public, :access_requestable) }
+ let(:group) { create(:group, :public) }
let(:group_member) do
group.request_access(user)
group.requesters.find_by(user_id: user.id)