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,42 +160,22 @@ module ChatMessage ...@@ -166,42 +160,22 @@ 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") when 'failed'
when 'failed' s_("ChatMessage|has failed")
s_("ChatMessage|has failed")
else
status
end
else else
case status status
when 'success'
s_("ChatMessage|passed")
when 'failed'
s_("ChatMessage|failed")
else
status
end
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
'danger'
end
else else
case status 'danger'
when 'success'
'good'
else
'danger'
end
end end
end end
...@@ -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,475 +55,324 @@ describe ChatMessage::PipelineMessage do ...@@ -55,475 +55,324 @@ 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 it 'returns an empty pretext' do
before do expect(subject.pretext).to be_empty
stub_feature_flags(fancy_pipeline_slack_notifications: false) end
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) has passed"
)
end
it 'returns an empty pretext' do context "when the pipeline failed" do
expect(subject.pretext).to be_empty before do
args[:object_attributes][:status] = 'failed'
end end
it "returns the pipeline summary in the activity's title" do it "returns the summary with a 'failed' status" do
expect(subject.activity[:title]).to eq( expect(subject.activity[:title]).to eq(
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \ "Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of branch [develop](http://example.gitlab.com/commits/develop)" \ " of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) passed" " by The Hacker (hacker) has failed"
) )
end end
end
context "when the pipeline failed" do context "when the pipeline passed with warnings" do
before do before do
args[:object_attributes][:status] = 'failed' args[:object_attributes][:detailed_status] = 'passed with warnings'
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 end
it "returns the pipeline summary as the attachment's text property" do it "returns the summary with a 'passed with warnings' status" do
expect(subject.attachments.first[:text]).to eq( expect(subject.activity[:title]).to eq(
"<http://example.gitlab.com|project_name>:" \ "Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" Pipeline <http://example.gitlab.com/pipelines/123|#123>" \ " of branch [develop](http://example.gitlab.com/commits/develop)" \
" of branch <http://example.gitlab.com/commits/develop|develop>" \ " by The Hacker (hacker) has passed with warnings"
" by The Hacker (hacker) passed in 02:00:10"
) )
end 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 end
context 'when the fancy_pipeline_slack_notifications feature flag is enabled' do context 'when no user is provided because the pipeline was triggered by the API' do
before do before do
stub_feature_flags(fancy_pipeline_slack_notifications: true) args[:user] = nil
end
it 'returns an empty pretext' do
expect(subject.pretext).to be_empty
end end
it "returns the pipeline summary in the activity's title" do it "returns the summary with 'API' as the username" do
expect(subject.activity[:title]).to eq( expect(subject.activity[:title]).to eq(
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \ "Pipeline [#123](http://example.gitlab.com/pipelines/123)" \
" of branch [develop](http://example.gitlab.com/commits/develop)" \ " of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) has passed" " by API has passed"
) )
end end
end
context "when the pipeline failed" do it "returns a link to the project in the activity's subtitle" do
before do expect(subject.activity[:subtitle]).to eq("in [project_name](http://example.gitlab.com)")
args[:object_attributes][:status] = 'failed' end
end
it "returns the summary with a 'failed' status" do it "returns the build duration in the activity's text property" do
expect(subject.activity[:title]).to eq( expect(subject.activity[:text]).to eq("in 02:00:10")
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \ end
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) has failed"
)
end
end
context "when the pipeline passed with warnings" do it "returns the user's avatar image URL in the activity's image property" do
before do expect(subject.activity[:image]).to eq("http://example.com/avatar")
args[:object_attributes][:detailed_status] = 'passed with warnings' end
end
it "returns the summary with a 'passed with warnings' status" do context 'when the user does not have an avatar' do
expect(subject.activity[:title]).to eq( before do
"Pipeline [#123](http://example.gitlab.com/pipelines/123)" \ args[:user][:avatar_url] = nil
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) has passed with warnings"
)
end
end end
context 'when no user is provided because the pipeline was triggered by the API' do it "returns an empty string in the activity's image property" do
before do expect(subject.activity[:image]).to be_empty
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 has passed"
)
end
end end
end
it "returns a link to the project in the activity's subtitle" do it "returns the pipeline summary as the attachment's fallback property" do
expect(subject.activity[:subtitle]).to eq("in [project_name](http://example.gitlab.com)") expect(subject.attachments.first[:fallback]).to eq(
end "<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) has passed in 02:00:10"
)
end
it "returns the build duration in the activity's text property" do it "returns 'good' as the attachment's color property" do
expect(subject.activity[:text]).to eq("in 02:00:10") expect(subject.attachments.first[:color]).to eq('good')
end end
it "returns the user's avatar image URL in the activity's image property" do context "when the pipeline failed" do
expect(subject.activity[:image]).to eq("http://example.com/avatar") before do
args[:object_attributes][:status] = 'failed'
end end
context 'when the user does not have an avatar' do it "returns 'danger' as the attachment's color property" do
before do expect(subject.attachments.first[:color]).to eq('danger')
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 end
end
it "returns the pipeline summary as the attachment's fallback property" do context "when the pipeline passed with warnings" do
expect(subject.attachments.first[:fallback]).to eq( before do
"<http://example.gitlab.com|project_name>:" \ args[:object_attributes][:detailed_status] = 'passed with warnings'
" Pipeline <http://example.gitlab.com/pipelines/123|#123>" \
" of branch <http://example.gitlab.com/commits/develop|develop>" \
" by The Hacker (hacker) has passed in 02:00:10"
)
end end
it "returns 'good' as the attachment's color property" do it "returns 'warning' as the attachment's color property" do
expect(subject.attachments.first[:color]).to eq('good') expect(subject.attachments.first[:color]).to eq('warning')
end end
end
context "when the pipeline failed" do it "returns the committer's name and username as the attachment's author_name property" do
before do expect(subject.attachments.first[:author_name]).to eq('The Hacker (hacker)')
args[:object_attributes][:status] = 'failed' end
end
it "returns 'danger' as the attachment's color property" do it "returns the committer's avatar URL as the attachment's author_icon property" do
expect(subject.attachments.first[:color]).to eq('danger') expect(subject.attachments.first[:author_icon]).to eq('http://example.com/avatar')
end end
end
context "when the pipeline passed with warnings" do it "returns the committer's GitLab profile URL as the attachment's author_link property" do
before do expect(subject.attachments.first[:author_link]).to eq('http://example.gitlab.com/hacker')
args[:object_attributes][:detailed_status] = 'passed with warnings' end
end
it "returns 'warning' as the attachment's color property" do context 'when no user is provided because the pipeline was triggered by the API' do
expect(subject.attachments.first[:color]).to eq('warning') before do
end args[:user] = nil
end end
it "returns the committer's name and username as the attachment's author_name property" do it "returns the committer's name and username as the attachment's author_name property" do
expect(subject.attachments.first[:author_name]).to eq('The Hacker (hacker)') expect(subject.attachments.first[:author_name]).to eq('API')
end end
it "returns the committer's avatar URL as the attachment's author_icon property" do it "returns nil as the attachment's author_icon property" do
expect(subject.attachments.first[:author_icon]).to eq('http://example.com/avatar') expect(subject.attachments.first[:author_icon]).to be_nil
end end
it "returns the committer's GitLab profile URL as the attachment's author_link property" do it "returns nil as the attachment's author_link property" do
expect(subject.attachments.first[:author_link]).to eq('http://example.gitlab.com/hacker') expect(subject.attachments.first[:author_link]).to be_nil
end end
end
context 'when no user is provided because the pipeline was triggered by the API' do it "returns the pipeline ID, status, and duration as the attachment's title property" do
before do expect(subject.attachments.first[:title]).to eq("Pipeline #123 has passed in 02:00:10")
args[:user] = nil end
end
it "returns the committer's name and username as the attachment's author_name property" do it "returns the pipeline URL as the attachment's title_link property" do
expect(subject.attachments.first[:author_name]).to eq('API') expect(subject.attachments.first[:title_link]).to eq("http://example.gitlab.com/pipelines/123")
end end
it "returns nil as the attachment's author_icon property" do it "returns two attachment fields" do
expect(subject.attachments.first[:author_icon]).to be_nil expect(subject.attachments.first[:fields].count).to eq(2)
end end
it "returns nil as the attachment's author_link property" do it "returns the commit message as the attachment's second field property" do
expect(subject.attachments.first[:author_link]).to be_nil expect(subject.attachments.first[:fields][0]).to eq({
end title: "Branch",
end value: "<http://example.gitlab.com/commits/develop|develop>",
short: true
})
end
it "returns the pipeline ID, status, and duration as the attachment's title property" do it "returns the ref name and link as the attachment's second field property" do
expect(subject.attachments.first[:title]).to eq("Pipeline #123 has passed in 02:00:10") expect(subject.attachments.first[:fields][1]).to eq({
end title: "Commit",
value: "<http://example.com/commit|A test commit message>",
short: true
})
end
it "returns the pipeline URL as the attachment's title_link property" do context "when a job in the pipeline fails" do
expect(subject.attachments.first[:title_link]).to eq("http://example.gitlab.com/pipelines/123") before do
args[:builds] = [
{ id: 1, name: "rspec", status: "failed", stage: "test" },
{ id: 2, name: "karma", status: "success", stage: "test" }
]
end end
it "returns two attachment fields" do it "returns four attachment fields" do
expect(subject.attachments.first[:fields].count).to eq(2) expect(subject.attachments.first[:fields].count).to eq(4)
end end
it "returns the commit message as the attachment's second field property" do it "returns the stage name and link to the 'Failed jobs' tab on the pipeline's page as the attachment's third field property" do
expect(subject.attachments.first[:fields][0]).to eq({ expect(subject.attachments.first[:fields][2]).to eq({
title: "Branch", title: "Failed stage",
value: "<http://example.gitlab.com/commits/develop|develop>", value: "<http://example.gitlab.com/pipelines/123/failures|test>",
short: true short: true
}) })
end end
it "returns the ref name and link as the attachment's second field property" do it "returns the job name and link as the attachment's fourth field property" do
expect(subject.attachments.first[:fields][1]).to eq({ expect(subject.attachments.first[:fields][3]).to eq({
title: "Commit", title: "Failed job",
value: "<http://example.com/commit|A test commit message>", value: "<http://example.gitlab.com/-/jobs/1|rspec>",
short: true short: true
}) })
end end
end
context "when a job in the pipeline fails" do context "when lots of jobs across multiple stages fail" do
before do before do
args[:builds] = [ args[:builds] = (1..25).map do |i|
{ id: 1, name: "rspec", status: "failed", stage: "test" }, { id: i, name: "job-#{i}", status: "failed", stage: "stage-" + ((i % 3) + 1).to_s }
{ id: 2, name: "karma", status: "success", stage: "test" }
]
end
it "returns four attachment fields" do
expect(subject.attachments.first[:fields].count).to eq(4)
end
it "returns the stage name and link to the 'Failed jobs' tab on the pipeline's page as the attachment's third field property" do
expect(subject.attachments.first[:fields][2]).to eq({
title: "Failed stage",
value: "<http://example.gitlab.com/pipelines/123/failures|test>",
short: true
})
end
it "returns the job name and link as the attachment's fourth field property" do
expect(subject.attachments.first[:fields][3]).to eq({
title: "Failed job",
value: "<http://example.gitlab.com/-/jobs/1|rspec>",
short: true
})
end end
end end
context "when lots of jobs across multiple stages fail" do it "returns the stage names and links to the 'Failed jobs' tab on the pipeline's page as the attachment's third field property" do
before do expect(subject.attachments.first[:fields][2]).to eq({
args[:builds] = (1..25).map do |i| title: "Failed stages",
{ id: i, name: "job-#{i}", status: "failed", stage: "stage-" + ((i % 3) + 1).to_s } value: "<http://example.gitlab.com/pipelines/123/failures|stage-2>, <http://example.gitlab.com/pipelines/123/failures|stage-1>, <http://example.gitlab.com/pipelines/123/failures|stage-3>",
end short: true
end })
end
it "returns the stage names and links to the 'Failed jobs' tab on the pipeline's page as the attachment's third field property" do it "returns the job names and links as the attachment's fourth field property" do
expect(subject.attachments.first[:fields][2]).to eq({ expected_jobs = 25.downto(16).map do |i|
title: "Failed stages", "<http://example.gitlab.com/-/jobs/#{i}|job-#{i}>"
value: "<http://example.gitlab.com/pipelines/123/failures|stage-2>, <http://example.gitlab.com/pipelines/123/failures|stage-1>, <http://example.gitlab.com/pipelines/123/failures|stage-3>",
short: true
})
end end
it "returns the job names and links as the attachment's fourth field property" do expected_jobs << "and <http://example.gitlab.com/pipelines/123/failures|15 more>"
expected_jobs = 25.downto(16).map do |i|
"<http://example.gitlab.com/-/jobs/#{i}|job-#{i}>"
end
expected_jobs << "and <http://example.gitlab.com/pipelines/123/failures|15 more>" expect(subject.attachments.first[:fields][3]).to eq({
title: "Failed jobs",
expect(subject.attachments.first[:fields][3]).to eq({ value: expected_jobs.join(", "),
title: "Failed jobs", short: true
value: expected_jobs.join(", "), })
short: true
})
end
end end
end
context "when jobs succeed on retries" do context "when jobs succeed on retries" do
before do before do
args[:builds] = [ args[:builds] = [
{ id: 1, name: "job-1", status: "failed", stage: "stage-1" }, { id: 1, name: "job-1", status: "failed", stage: "stage-1" },
{ id: 2, name: "job-2", status: "failed", stage: "stage-2" }, { id: 2, name: "job-2", status: "failed", stage: "stage-2" },
{ id: 3, name: "job-3", status: "failed", stage: "stage-3" }, { id: 3, name: "job-3", status: "failed", stage: "stage-3" },
{ id: 7, name: "job-1", status: "failed", stage: "stage-1" }, { id: 7, name: "job-1", status: "failed", stage: "stage-1" },
{ id: 8, name: "job-1", status: "success", stage: "stage-1" } { id: 8, name: "job-1", status: "success", stage: "stage-1" }
] ]
end end
it "do not return a job which succeeded on retry" do it "do not return a job which succeeded on retry" do
expected_jobs = [ expected_jobs = [
"<http://example.gitlab.com/-/jobs/3|job-3>", "<http://example.gitlab.com/-/jobs/3|job-3>",
"<http://example.gitlab.com/-/jobs/2|job-2>" "<http://example.gitlab.com/-/jobs/2|job-2>"
] ]
expect(subject.attachments.first[:fields][3]).to eq( expect(subject.attachments.first[:fields][3]).to eq(
title: "Failed jobs", title: "Failed jobs",
value: expected_jobs.join(", "), value: expected_jobs.join(", "),
short: true short: true
) )
end
end end
end
context "when jobs failed even on retries" do context "when jobs failed even on retries" do
before do before do
args[:builds] = [ args[:builds] = [
{ id: 1, name: "job-1", status: "failed", stage: "stage-1" }, { id: 1, name: "job-1", status: "failed", stage: "stage-1" },
{ id: 2, name: "job-2", status: "failed", stage: "stage-2" }, { id: 2, name: "job-2", status: "failed", stage: "stage-2" },
{ id: 3, name: "job-3", status: "failed", stage: "stage-3" }, { id: 3, name: "job-3", status: "failed", stage: "stage-3" },
{ id: 7, name: "job-1", status: "failed", stage: "stage-1" }, { id: 7, name: "job-1", status: "failed", stage: "stage-1" },
{ id: 8, name: "job-1", status: "failed", stage: "stage-1" } { id: 8, name: "job-1", status: "failed", stage: "stage-1" }
] ]
end end
it "returns only first instance of the failed job" do it "returns only first instance of the failed job" do
expected_jobs = [ expected_jobs = [
"<http://example.gitlab.com/-/jobs/3|job-3>", "<http://example.gitlab.com/-/jobs/3|job-3>",
"<http://example.gitlab.com/-/jobs/2|job-2>", "<http://example.gitlab.com/-/jobs/2|job-2>",
"<http://example.gitlab.com/-/jobs/1|job-1>" "<http://example.gitlab.com/-/jobs/1|job-1>"
] ]
expect(subject.attachments.first[:fields][3]).to eq( expect(subject.attachments.first[:fields][3]).to eq(
title: "Failed jobs", title: "Failed jobs",
value: expected_jobs.join(", "), value: expected_jobs.join(", "),
short: true short: true
) )
end
end end
end
context "when the CI config file contains a YAML error" do context "when the CI config file contains a YAML error" do
let(:has_yaml_errors) { true } let(:has_yaml_errors) { true }
it "returns three attachment fields" do
expect(subject.attachments.first[:fields].count).to eq(3)
end
it "returns the YAML error deatils as the attachment's third field property" do it "returns three attachment fields" do
expect(subject.attachments.first[:fields][2]).to eq({ expect(subject.attachments.first[:fields].count).to eq(3)
title: "Invalid CI config YAML file",
value: "yaml error description here",
short: false
})
end
end end
it "returns the project's name as the attachment's footer property" do it "returns the YAML error deatils as the attachment's third field property" do
expect(subject.attachments.first[:footer]).to eq("project_name") expect(subject.attachments.first[:fields][2]).to eq({
title: "Invalid CI config YAML file",
value: "yaml error description here",
short: false
})
end end
end
it "returns the project's avatar URL as the attachment's footer_icon property" do it "returns the project's name as the attachment's footer property" do
expect(subject.attachments.first[:footer_icon]).to eq("http://example.com/project_avatar") expect(subject.attachments.first[:footer]).to eq("project_name")
end end
it "returns the pipeline's timestamp as the attachment's ts property" do it "returns the project's avatar URL as the attachment's footer_icon property" do
expected_ts = Time.parse(args[:object_attributes][:finished_at]).to_i expect(subject.attachments.first[:footer_icon]).to eq("http://example.com/project_avatar")
expect(subject.attachments.first[:ts]).to eq(expected_ts) end
end
context 'when rendering markdown' do it "returns the pipeline's timestamp as the attachment's ts property" do
before do expected_ts = Time.parse(args[:object_attributes][:finished_at]).to_i
args[:markdown] = true expect(subject.attachments.first[:ts]).to eq(expected_ts)
end end
it 'returns the pipeline summary as the attachments in markdown format' do context 'when rendering markdown' do
expect(subject.attachments).to eq( before do
"[project_name](http://example.gitlab.com):" \ args[:markdown] = true
" Pipeline [#123](http://example.gitlab.com/pipelines/123)" \ end
" of branch [develop](http://example.gitlab.com/commits/develop)" \
" by The Hacker (hacker) has passed in 02:00:10" it 'returns the pipeline summary as the attachments in markdown format' do
) expect(subject.attachments).to eq(
end "[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) has passed in 02:00:10"
)
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