Commit 11ba759d authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '24107-slack-comment-link' into 'master'

Change the slack notification comment link.

## What does this MR do?

Changes the link in Slack notifications for comments.

## What are the relevant issue numbers?

Closes #24107

See merge request !7498
parents c69e3942 ca89b6e3
...@@ -46,25 +46,25 @@ class SlackService ...@@ -46,25 +46,25 @@ class SlackService
commit_sha = commit[:id] commit_sha = commit[:id]
commit_sha = Commit.truncate_sha(commit_sha) commit_sha = Commit.truncate_sha(commit_sha)
commented_on_message( commented_on_message(
"[commit #{commit_sha}](#{@note_url})", "commit #{commit_sha}",
format_title(commit[:message])) format_title(commit[:message]))
end end
def create_issue_note(issue) def create_issue_note(issue)
commented_on_message( commented_on_message(
"[issue ##{issue[:iid]}](#{@note_url})", "issue ##{issue[:iid]}",
format_title(issue[:title])) format_title(issue[:title]))
end end
def create_merge_note(merge_request) def create_merge_note(merge_request)
commented_on_message( commented_on_message(
"[merge request !#{merge_request[:iid]}](#{@note_url})", "merge request !#{merge_request[:iid]}",
format_title(merge_request[:title])) format_title(merge_request[:title]))
end end
def create_snippet_note(snippet) def create_snippet_note(snippet)
commented_on_message( commented_on_message(
"[snippet ##{snippet[:id]}](#{@note_url})", "snippet ##{snippet[:id]}",
format_title(snippet[:title])) format_title(snippet[:title]))
end end
...@@ -76,8 +76,8 @@ class SlackService ...@@ -76,8 +76,8 @@ class SlackService
"[#{@project_name}](#{@project_url})" "[#{@project_name}](#{@project_url})"
end end
def commented_on_message(target_link, title) def commented_on_message(target, title)
@message = "#{@user_name} commented on #{target_link} in #{project_link}: *#{title}*" @message = "#{@user_name} [commented on #{target}](#{@note_url}) in #{project_link}: *#{title}*"
end end
end end
end end
---
title: Change slack notification comment link
merge_request: 7498
author: Herbert Kagumba
...@@ -37,8 +37,8 @@ describe SlackService::NoteMessage, models: true do ...@@ -37,8 +37,8 @@ describe SlackService::NoteMessage, models: true do
it 'returns a message regarding notes on commits' do it 'returns a message regarding notes on commits' do
message = SlackService::NoteMessage.new(@args) message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq("test.user commented on " \ expect(message.pretext).to eq("test.user <url|commented on " \
"<url|commit 5f163b2b> in <somewhere.com|project_name>: " \ "commit 5f163b2b> in <somewhere.com|project_name>: " \
"*Added a commit message*") "*Added a commit message*")
expected_attachments = [ expected_attachments = [
{ {
...@@ -63,8 +63,8 @@ describe SlackService::NoteMessage, models: true do ...@@ -63,8 +63,8 @@ describe SlackService::NoteMessage, models: true do
it 'returns a message regarding notes on a merge request' do it 'returns a message regarding notes on a merge request' do
message = SlackService::NoteMessage.new(@args) message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq("test.user commented on " \ expect(message.pretext).to eq("test.user <url|commented on " \
"<url|merge request !30> in <somewhere.com|project_name>: " \ "merge request !30> in <somewhere.com|project_name>: " \
"*merge request title*") "*merge request title*")
expected_attachments = [ expected_attachments = [
{ {
...@@ -90,8 +90,8 @@ describe SlackService::NoteMessage, models: true do ...@@ -90,8 +90,8 @@ describe SlackService::NoteMessage, models: true do
it 'returns a message regarding notes on an issue' do it 'returns a message regarding notes on an issue' do
message = SlackService::NoteMessage.new(@args) message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq( expect(message.pretext).to eq(
"test.user commented on " \ "test.user <url|commented on " \
"<url|issue #20> in <somewhere.com|project_name>: " \ "issue #20> in <somewhere.com|project_name>: " \
"*issue title*") "*issue title*")
expected_attachments = [ expected_attachments = [
{ {
...@@ -115,8 +115,8 @@ describe SlackService::NoteMessage, models: true do ...@@ -115,8 +115,8 @@ describe SlackService::NoteMessage, models: true do
it 'returns a message regarding notes on a project snippet' do it 'returns a message regarding notes on a project snippet' do
message = SlackService::NoteMessage.new(@args) message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq("test.user commented on " \ expect(message.pretext).to eq("test.user <url|commented on " \
"<url|snippet #5> in <somewhere.com|project_name>: " \ "snippet #5> in <somewhere.com|project_name>: " \
"*snippet title*") "*snippet title*")
expected_attachments = [ expected_attachments = [
{ {
......
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