From 5e7d68ef798c110204351ec089acd896271c4315 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Mon, 6 Nov 2017 13:48:34 +0000 Subject: [PATCH] Fix issue reopen Mattermost / Slack message When an issue is reopened, the action is 'reopen', but the state is 'opened' (as we don't have a separate 'reopened' state any more). Because we checked the action in one method and the state in another, this lead to a weird case where the mesage neither linked to the issue, nor contained an attachment with its details. Just checking the action is fine, as it's the most granular. --- .../project_services/chat_message/issue_message.rb | 2 +- ...ost-notification-has-no-context-to-the-issue.yml | 5 +++++ .../chat_message/issue_message_spec.rb | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/39791-when-reopening-an-issue-the-mattermost-notification-has-no-context-to-the-issue.yml diff --git a/app/models/project_services/chat_message/issue_message.rb b/app/models/project_services/chat_message/issue_message.rb index 1327b075858..3273f41dbd2 100644 --- a/app/models/project_services/chat_message/issue_message.rb +++ b/app/models/project_services/chat_message/issue_message.rb @@ -39,7 +39,7 @@ module ChatMessage private def message - if state == 'opened' + if opened_issue? "[#{project_link}] Issue #{state} by #{user_combined_name}" else "[#{project_link}] Issue #{issue_link} #{state} by #{user_combined_name}" diff --git a/changelogs/unreleased/39791-when-reopening-an-issue-the-mattermost-notification-has-no-context-to-the-issue.yml b/changelogs/unreleased/39791-when-reopening-an-issue-the-mattermost-notification-has-no-context-to-the-issue.yml new file mode 100644 index 00000000000..143641c6183 --- /dev/null +++ b/changelogs/unreleased/39791-when-reopening-an-issue-the-mattermost-notification-has-no-context-to-the-issue.yml @@ -0,0 +1,5 @@ +--- +title: Include link to issue in reopen message for Slack and Mattermost notifications +merge_request: +author: +type: fixed diff --git a/spec/models/project_services/chat_message/issue_message_spec.rb b/spec/models/project_services/chat_message/issue_message_spec.rb index d37726dc3f1..f7a35fdc88a 100644 --- a/spec/models/project_services/chat_message/issue_message_spec.rb +++ b/spec/models/project_services/chat_message/issue_message_spec.rb @@ -66,6 +66,19 @@ describe ChatMessage::IssueMessage do expect(subject.attachments).to be_empty end end + + context 'reopen' do + before do + args[:object_attributes][:action] = 'reopen' + args[:object_attributes][:state] = 'opened' + end + + it 'returns a message regarding reopening of issues' do + expect(subject.pretext) + .to eq('[] Issue opened by Test User (test.user)') + expect(subject.attachments).to be_empty + end + end end context 'with markdown' do