Commit b486ee40 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'nfriend-remove-fancy_pipeline_slack_notifications-ff' into 'master'

Remove `fancy_pipeline_slack_notifications` feature flag

See merge request gitlab-org/gitlab!29969
parents 3233d6f9 559bb7c3
...@@ -52,8 +52,6 @@ module ChatMessage ...@@ -52,8 +52,6 @@ module ChatMessage
def attachments def attachments
return message if markdown return message if markdown
return [{ text: format(message), color: attachment_color }] unless fancy_notifications?
[{ [{
fallback: format(message), fallback: format(message),
color: attachment_color, color: attachment_color,
...@@ -103,10 +101,6 @@ module ChatMessage ...@@ -103,10 +101,6 @@ module ChatMessage
failed_jobs.uniq { |job| job[:name] }.reverse failed_jobs.uniq { |job| job[:name] }.reverse
end end
def fancy_notifications?
Feature.enabled?(:fancy_pipeline_slack_notifications, default_enabled: true)
end
def failed_stages_field def failed_stages_field
{ {
title: s_("ChatMessage|Failed stage").pluralize(failed_stages.length), title: s_("ChatMessage|Failed stage").pluralize(failed_stages.length),
...@@ -166,7 +160,6 @@ module ChatMessage ...@@ -166,7 +160,6 @@ module ChatMessage
end end
def humanized_status def humanized_status
if fancy_notifications?
case status case status
when 'success' when 'success'
detailed_status == "passed with warnings" ? s_("ChatMessage|has passed with warnings") : s_("ChatMessage|has passed") detailed_status == "passed with warnings" ? s_("ChatMessage|has passed with warnings") : s_("ChatMessage|has passed")
...@@ -175,34 +168,15 @@ module ChatMessage ...@@ -175,34 +168,15 @@ module ChatMessage
else else
status status
end end
else
case status
when 'success'
s_("ChatMessage|passed")
when 'failed'
s_("ChatMessage|failed")
else
status
end
end
end end
def attachment_color def attachment_color
if fancy_notifications?
case status case status
when 'success' when 'success'
detailed_status == 'passed with warnings' ? 'warning' : 'good' detailed_status == 'passed with warnings' ? 'warning' : 'good'
else else
'danger' 'danger'
end end
else
case status
when 'success'
'good'
else
'danger'
end
end
end end
def ref_url def ref_url
...@@ -230,7 +204,7 @@ module ChatMessage ...@@ -230,7 +204,7 @@ module ChatMessage
end end
def pipeline_url def pipeline_url
if fancy_notifications? && failed_jobs.any? if failed_jobs.any?
pipeline_failed_jobs_url pipeline_failed_jobs_url
else else
"#{project_url}/pipelines/#{pipeline_id}" "#{project_url}/pipelines/#{pipeline_id}"
......
...@@ -3639,9 +3639,6 @@ msgstr "" ...@@ -3639,9 +3639,6 @@ msgstr ""
msgid "ChatMessage|and [%{count} more](%{pipeline_failed_jobs_url})" msgid "ChatMessage|and [%{count} more](%{pipeline_failed_jobs_url})"
msgstr "" msgstr ""
msgid "ChatMessage|failed"
msgstr ""
msgid "ChatMessage|has failed" msgid "ChatMessage|has failed"
msgstr "" msgstr ""
...@@ -3657,9 +3654,6 @@ msgstr "" ...@@ -3657,9 +3654,6 @@ msgstr ""
msgid "ChatMessage|in %{project_link}" msgid "ChatMessage|in %{project_link}"
msgstr "" msgstr ""
msgid "ChatMessage|passed"
msgstr ""
msgid "Check again" msgid "Check again"
msgstr "" msgstr ""
......
...@@ -55,156 +55,6 @@ describe ChatMessage::PipelineMessage do ...@@ -55,156 +55,6 @@ describe ChatMessage::PipelineMessage do
allow(Gitlab::UrlBuilder).to receive(:build).with(args[:user]).and_return("http://example.gitlab.com/hacker") allow(Gitlab::UrlBuilder).to receive(:build).with(args[:user]).and_return("http://example.gitlab.com/hacker")
end 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 it 'returns an empty pretext' do
expect(subject.pretext).to be_empty expect(subject.pretext).to be_empty
end end
...@@ -525,5 +375,4 @@ describe ChatMessage::PipelineMessage do ...@@ -525,5 +375,4 @@ describe ChatMessage::PipelineMessage do
) )
end end
end 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