Commit 559bb7c3 authored by Nathan Friend's avatar Nathan Friend

Remove `fancy_pipeline_slack_notifications` flag

This commit removes the `fancy_pipeline_slack_notifications` feature
flag and associated code paths and tests.
parent 5a1e492b
......@@ -52,8 +52,6 @@ module ChatMessage
def attachments
return message if markdown
return [{ text: format(message), color: attachment_color }] unless fancy_notifications?
[{
fallback: format(message),
color: attachment_color,
......@@ -103,10 +101,6 @@ module ChatMessage
failed_jobs.uniq { |job| job[:name] }.reverse
end
def fancy_notifications?
Feature.enabled?(:fancy_pipeline_slack_notifications, default_enabled: true)
end
def failed_stages_field
{
title: s_("ChatMessage|Failed stage").pluralize(failed_stages.length),
......@@ -166,7 +160,6 @@ module ChatMessage
end
def humanized_status
if fancy_notifications?
case status
when 'success'
detailed_status == "passed with warnings" ? s_("ChatMessage|has passed with warnings") : s_("ChatMessage|has passed")
......@@ -175,34 +168,15 @@ module ChatMessage
else
status
end
else
case status
when 'success'
s_("ChatMessage|passed")
when 'failed'
s_("ChatMessage|failed")
else
status
end
end
end
def attachment_color
if fancy_notifications?
case status
when 'success'
detailed_status == 'passed with warnings' ? 'warning' : 'good'
else
'danger'
end
else
case status
when 'success'
'good'
else
'danger'
end
end
end
def ref_url
......@@ -230,7 +204,7 @@ module ChatMessage
end
def pipeline_url
if fancy_notifications? && failed_jobs.any?
if failed_jobs.any?
pipeline_failed_jobs_url
else
"#{project_url}/pipelines/#{pipeline_id}"
......
......@@ -3633,9 +3633,6 @@ msgstr ""
msgid "ChatMessage|and [%{count} more](%{pipeline_failed_jobs_url})"
msgstr ""
msgid "ChatMessage|failed"
msgstr ""
msgid "ChatMessage|has failed"
msgstr ""
......@@ -3651,9 +3648,6 @@ msgstr ""
msgid "ChatMessage|in %{project_link}"
msgstr ""
msgid "ChatMessage|passed"
msgstr ""
msgid "Check again"
msgstr ""
......
......@@ -55,156 +55,6 @@ describe ChatMessage::PipelineMessage do
allow(Gitlab::UrlBuilder).to receive(:build).with(args[:user]).and_return("http://example.gitlab.com/hacker")
end
context 'when the fancy_pipeline_slack_notifications feature flag is disabled' do
before do
stub_feature_flags(fancy_pipeline_slack_notifications: false)
end
it 'returns an empty pretext' do
expect(subject.pretext).to be_empty
end
it "returns the pipeline summary in the activity's title" do
expect(subject.activity[:title]).to eq(
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) passed"
)
end
context "when the pipeline failed" do
before do
args[:object_attributes][:status] = 'failed'
end
it "returns the summary with a 'failed' status" do
expect(subject.activity[:title]).to eq(
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) failed"
)
end
end
context 'when no user is provided because the pipeline was triggered by the API' do
before do
args[:user] = nil
end
it "returns the summary with 'API' as the username" do
expect(subject.activity[:title]).to eq(
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by API passed"
)
end
end
it "returns a link to the project in the activity's subtitle" do
expect(subject.activity[:subtitle]).to eq("in [project_name](http://example.gitlab.com)")
end
it "returns the build duration in the activity's text property" do
expect(subject.activity[:text]).to eq("in 02:00:10")
end
it "returns the user's avatar image URL in the activity's image property" do
expect(subject.activity[:image]).to eq("http://example.com/avatar")
end
context 'when the user does not have an avatar' do
before do
args[:user][:avatar_url] = nil
end
it "returns an empty string in the activity's image property" do
expect(subject.activity[:image]).to be_empty
end
end
it "returns the pipeline summary as the attachment's text property" do
expect(subject.attachments.first[:text]).to eq(
"<http://example.gitlab.com|project_name>:" \
" Pipeline <http://example.gitlab.com/pipelines/123|#123>" \
" of branch <http://example.gitlab.com/commits/develop|develop>" \
" by The Hacker (hacker) passed in 02:00:10"
)
end
it "returns 'good' as the attachment's color property" do
expect(subject.attachments.first[:color]).to eq('good')
end
context "when the pipeline failed" do
before do
args[:object_attributes][:status] = 'failed'
end
it "returns 'danger' as the attachment's color property" do
expect(subject.attachments.first[:color]).to eq('danger')
end
end
context 'when rendering markdown' do
before do
args[:markdown] = true
end
it 'returns the pipeline summary as the attachments in markdown format' do
expect(subject.attachments).to eq(
"[project_name](http://example.gitlab.com):" \
" Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) passed in 02:00:10"
)
end
end
context 'when ref type is tag' do
before do
args[:object_attributes][:tag] = true
args[:object_attributes][:ref] = 'new_tag'
end
it "returns the pipeline summary in the activity's title" do
expect(subject.activity[:title]).to eq(
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of tag [new_tag](http://example.gitlab.com/-/tags/new_tag)" \
" by The Hacker (hacker) passed"
)
end
it "returns the pipeline summary as the attachment's text property" do
expect(subject.attachments.first[:text]).to eq(
"<http://example.gitlab.com|project_name>:" \
" Pipeline <http://example.gitlab.com/pipelines/123|#123>" \
" of tag <http://example.gitlab.com/-/tags/new_tag|new_tag>" \
" by The Hacker (hacker) passed in 02:00:10"
)
end
context 'when rendering markdown' do
before do
args[:markdown] = true
end
it 'returns the pipeline summary as the attachments in markdown format' do
expect(subject.attachments).to eq(
"[project_name](http://example.gitlab.com):" \
" Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of tag [new_tag](http://example.gitlab.com/-/tags/new_tag)" \
" by The Hacker (hacker) passed in 02:00:10"
)
end
end
end
end
context 'when the fancy_pipeline_slack_notifications feature flag is enabled' do
before do
stub_feature_flags(fancy_pipeline_slack_notifications: true)
end
it 'returns an empty pretext' do
expect(subject.pretext).to be_empty
end
......@@ -525,5 +375,4 @@ describe ChatMessage::PipelineMessage do
)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment