debian-mirror-gitlab/spec/views/notify/pipeline_failed_email.text.erb_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.8 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'notify/pipeline_failed_email.text.erb' do
2019-07-31 22:56:46 +05:30
include Devise::Test::ControllerHelpers
2019-09-04 21:01:54 +05:30
let(:user) { create(:user, developer_projects: [project]) }
2019-07-31 22:56:46 +05:30
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, :simple, source_project: project) }
let(:pipeline) do
2023-06-20 00:43:36 +05:30
create(
:ci_pipeline,
:failed,
project: project,
user: user,
ref: project.default_branch,
sha: project.commit.sha
)
2019-07-31 22:56:46 +05:30
end
before do
assign(:project, project)
assign(:pipeline, pipeline)
assign(:merge_request, merge_request)
end
2020-03-13 15:44:24 +05:30
shared_examples_for 'renders the pipeline failed email correctly' do
it 'renders the email correctly' do
render
2021-03-08 18:12:59 +05:30
expect(rendered).to have_content("Pipeline ##{pipeline.id} has failed!")
2020-03-13 15:44:24 +05:30
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'
2019-07-31 22:56:46 +05:30
end
2019-12-21 20:55:43 +05:30
2020-03-13 15:44:24 +05:30
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
2019-07-31 22:56:46 +05:30
end