2019-10-08 08:06:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-27 03:57:52 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'notify/pipeline_failed_email.html.haml' do
|
|
|
|
include Devise::Test::ControllerHelpers
|
|
|
|
|
2019-04-11 11:21:18 -04:00
|
|
|
let(:user) { create(:user, developer_projects: [project]) }
|
2017-08-01 14:51:52 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-03-27 03:57:52 -04:00
|
|
|
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 failed"
|
|
|
|
expect(rendered).to have_content pipeline.project.name
|
2019-06-25 13:54:42 -04:00
|
|
|
expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' ')
|
2017-03-27 03:57:52 -04:00
|
|
|
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
|
2019-09-27 11:06:16 -04:00
|
|
|
|
|
|
|
it_behaves_like 'correct pipeline information for pipelines for merge requests'
|
2017-03-27 03:57:52 -04:00
|
|
|
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
|
2019-06-25 13:54:42 -04:00
|
|
|
expect(rendered).to have_content pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' ')
|
2017-03-27 03:57:52 -04:00
|
|
|
expect(rendered).to have_content pipeline.commit.author_name
|
|
|
|
expect(rendered).to have_content "##{pipeline.id}"
|
|
|
|
expect(rendered).to have_content "by API"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|