summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:21 +0000
commite0fa0638a422c3e20d4423c9bb69d79afc9c7d3d (patch)
tree9abb3c0706576bbda895fe9539a55556930606e2 /spec/views
parentf8d15ca65390475e356b06dedc51e10ccd179f86 (diff)
downloadgitlab-ce-e0fa0638a422c3e20d4423c9bb69d79afc9c7d3d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/notify/pipeline_failed_email.html.haml_spec.rb70
-rw-r--r--spec/views/notify/pipeline_fixed_email.html.haml_spec.rb10
-rw-r--r--spec/views/notify/pipeline_fixed_email.text.erb_spec.rb10
-rw-r--r--spec/views/notify/pipeline_success_email.html.haml_spec.rb54
-rw-r--r--spec/views/notify/pipeline_success_email.text.erb_spec.rb22
5 files changed, 29 insertions, 137 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 a540a53c91d..80dc14b523d 100644
--- a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
@@ -3,72 +3,8 @@
require 'spec_helper'
describe 'notify/pipeline_failed_email.html.haml' do
- include Devise::Test::ControllerHelpers
-
- let(:user) { create(:user, developer_projects: [project]) }
- let(:project) { create(:project, :repository) }
- let(:merge_request) { create(:merge_request, :simple, source_project: project) }
-
- let(:pipeline) do
- create(:ci_pipeline,
- project: project,
- user: user,
- ref: project.default_branch,
- sha: project.commit.sha,
- status: :failed)
- end
-
- before do
- assign(:project, project)
- assign(:pipeline, pipeline)
- assign(:merge_request, merge_request)
- end
-
- 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 build.name
- 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
-
- 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
-
- 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'
+ it_behaves_like 'pipeline status changes email' do
+ let(:title) { 'Your pipeline has failed' }
+ let(:status) { :failed }
end
end
diff --git a/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb b/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb
new file mode 100644
index 00000000000..382fc5ecdd3
--- /dev/null
+++ b/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'notify/pipeline_fixed_email.html.haml' do
+ it_behaves_like 'pipeline status changes email' do
+ let(:title) { 'Your pipeline has been fixed!' }
+ let(:status) { :success }
+ end
+end
diff --git a/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb b/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb
new file mode 100644
index 00000000000..ec540dc3f77
--- /dev/null
+++ b/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'notify/pipeline_fixed_email.text.erb' do
+ it_behaves_like 'pipeline status changes email' do
+ let(:title) { 'Your pipeline has been fixed!' }
+ let(:status) { :success }
+ end
+end
diff --git a/spec/views/notify/pipeline_success_email.html.haml_spec.rb b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
index fbf33b7ec35..417909fd67b 100644
--- a/spec/views/notify/pipeline_success_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
@@ -3,56 +3,8 @@
require 'spec_helper'
describe 'notify/pipeline_success_email.html.haml' do
- include Devise::Test::ControllerHelpers
-
- let(:user) { create(:user, developer_projects: [project]) }
- let(:project) { create(:project, :repository) }
- let(:merge_request) { create(:merge_request, :simple, source_project: project) }
-
- let(:pipeline) do
- create(:ci_pipeline,
- project: project,
- user: user,
- ref: project.default_branch,
- sha: project.commit.sha,
- status: :success)
- end
-
- before do
- assign(:project, project)
- assign(:pipeline, pipeline)
- assign(:merge_request, merge_request)
- end
-
- context 'pipeline with user' do
- it 'renders the email correctly' do
- render
-
- expect(rendered).to have_content "Your pipeline has passed"
- 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
- 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
-
- it 'renders the email correctly' do
- render
-
- expect(rendered).to have_content "Your pipeline has passed"
- 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 'pipeline status changes email' do
+ let(:title) { 'Your pipeline has passed' }
+ let(:status) { :success }
end
end
diff --git a/spec/views/notify/pipeline_success_email.text.erb_spec.rb b/spec/views/notify/pipeline_success_email.text.erb_spec.rb
index ba4633bc346..4a914cab85e 100644
--- a/spec/views/notify/pipeline_success_email.text.erb_spec.rb
+++ b/spec/views/notify/pipeline_success_email.text.erb_spec.rb
@@ -3,24 +3,8 @@
require 'spec_helper'
describe 'notify/pipeline_success_email.text.erb' do
- let(:user) { create(:user, developer_projects: [project]) }
- let(:project) { create(:project, :repository) }
- let(:merge_request) { create(:merge_request, :simple, source_project: project) }
-
- let(:pipeline) do
- create(:ci_pipeline,
- :success,
- project: project,
- user: user,
- ref: project.default_branch,
- sha: project.commit.sha)
- end
-
- before do
- assign(:project, project)
- assign(:pipeline, pipeline)
- assign(:merge_request, merge_request)
+ it_behaves_like 'pipeline status changes email' do
+ let(:title) { 'Your pipeline has passed' }
+ let(:status) { :success }
end
-
- it_behaves_like 'correct pipeline information for pipelines for merge requests'
end