summaryrefslogtreecommitdiff
path: root/spec/views/notify
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-27 06:08:57 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-27 06:08:57 +0000
commiteace733dca6e5c87315b42f42eb4d8f05934d6de (patch)
treeba737686a8c8e5cc12a298db4303c60680e86e00 /spec/views/notify
parentc25c2a635b1944f5811d7a5eb9984ce5999e64f6 (diff)
downloadgitlab-ce-eace733dca6e5c87315b42f42eb4d8f05934d6de.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views/notify')
-rw-r--r--spec/views/notify/pipeline_failed_email.html.haml_spec.rb64
-rw-r--r--spec/views/notify/pipeline_failed_email.text.erb_spec.rb38
2 files changed, 65 insertions, 37 deletions
diff --git a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
index b821b015c97..a540a53c91d 100644
--- a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
@@ -15,7 +15,7 @@ describe 'notify/pipeline_failed_email.html.haml' do
user: user,
ref: project.default_branch,
sha: project.commit.sha,
- status: :success)
+ status: :failed)
end
before do
@@ -24,35 +24,51 @@ describe 'notify/pipeline_failed_email.html.haml' do
assign(:merge_request, merge_request)
end
- context 'pipeline with user' do
- it 'renders the email correctly' do
- render
+ shared_examples_for 'renders the pipeline failed email correctly' do
+ context 'pipeline with user' do
+ it 'renders the email correctly' do
+ render
- expect(rendered).to have_content "Your pipeline has failed"
- expect(rendered).to have_content pipeline.project.name
- expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' ')
- expect(rendered).to have_content pipeline.commit.author_name
- expect(rendered).to have_content "##{pipeline.id}"
- expect(rendered).to have_content pipeline.user.name
+ expect(rendered).to have_content "Your pipeline has failed"
+ expect(rendered).to have_content pipeline.project.name
+ expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' ')
+ expect(rendered).to have_content pipeline.commit.author_name
+ expect(rendered).to have_content "##{pipeline.id}"
+ expect(rendered).to have_content pipeline.user.name
+ expect(rendered).to have_content build.name
+ end
+
+ it_behaves_like 'correct pipeline information for pipelines for merge requests'
end
- it_behaves_like 'correct pipeline information for pipelines for merge requests'
- end
+ context 'pipeline without user' do
+ before do
+ pipeline.update_attribute(:user, nil)
+ end
- context 'pipeline without user' do
- before do
- pipeline.update_attribute(:user, nil)
+ it 'renders the email correctly' do
+ render
+
+ expect(rendered).to have_content "Your pipeline has failed"
+ expect(rendered).to have_content pipeline.project.name
+ expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' ')
+ expect(rendered).to have_content pipeline.commit.author_name
+ expect(rendered).to have_content "##{pipeline.id}"
+ expect(rendered).to have_content "by API"
+ expect(rendered).to have_content build.name
+ end
end
+ end
- it 'renders the email correctly' do
- render
+ context 'when the pipeline contains a failed job' do
+ let!(:build) { create(:ci_build, :failed, pipeline: pipeline, project: pipeline.project) }
- expect(rendered).to have_content "Your pipeline has failed"
- expect(rendered).to have_content pipeline.project.name
- expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' ')
- expect(rendered).to have_content pipeline.commit.author_name
- expect(rendered).to have_content "##{pipeline.id}"
- expect(rendered).to have_content "by API"
- end
+ it_behaves_like 'renders the pipeline failed email correctly'
+ end
+
+ context 'when the latest failed job is a bridge job' do
+ let!(:build) { create(:ci_bridge, status: :failed, pipeline: pipeline, project: pipeline.project) }
+
+ it_behaves_like 'renders the pipeline failed email correctly'
end
end
diff --git a/spec/views/notify/pipeline_failed_email.text.erb_spec.rb b/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
index d15969acf83..9a4cea408a6 100644
--- a/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
@@ -23,19 +23,31 @@ describe 'notify/pipeline_failed_email.text.erb' do
assign(:merge_request, merge_request)
end
- it 'renders the email correctly' do
- job = create(:ci_build, :failed, pipeline: pipeline, project: pipeline.project)
-
- render
-
- expect(rendered).to have_content('Your pipeline has failed')
- expect(rendered).to have_content(pipeline.project.name)
- expect(rendered).to have_content(pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' '))
- expect(rendered).to have_content(pipeline.commit.author_name)
- expect(rendered).to have_content("##{pipeline.id}")
- expect(rendered).to have_content(pipeline.user.name)
- expect(rendered).to have_content("/-/jobs/#{job.id}/raw")
+ shared_examples_for 'renders the pipeline failed email correctly' do
+ it 'renders the email correctly' do
+ render
+
+ expect(rendered).to have_content('Your pipeline has failed')
+ expect(rendered).to have_content(pipeline.project.name)
+ expect(rendered).to have_content(pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' '))
+ expect(rendered).to have_content(pipeline.commit.author_name)
+ expect(rendered).to have_content("##{pipeline.id}")
+ expect(rendered).to have_content(pipeline.user.name)
+ expect(rendered).to have_content(build.id)
+ end
+
+ it_behaves_like 'correct pipeline information for pipelines for merge requests'
end
- it_behaves_like 'correct pipeline information for pipelines for merge requests'
+ context 'when the pipeline contains a failed job' do
+ let!(:build) { create(:ci_build, :failed, pipeline: pipeline, project: pipeline.project) }
+
+ it_behaves_like 'renders the pipeline failed email correctly'
+ end
+
+ context 'when the latest failed job is a bridge job' do
+ let!(:build) { create(:ci_bridge, status: :failed, pipeline: pipeline, project: pipeline.project) }
+
+ it_behaves_like 'renders the pipeline failed email correctly'
+ end
end