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.
This commit is contained in:
Sean McGivern 2017-11-06 13:48:34 +00:00
parent cfc932cad1
commit 5e7d68ef79
3 changed files with 19 additions and 1 deletions

View file

@ -39,7 +39,7 @@ module ChatMessage
private private
def message def message
if state == 'opened' if opened_issue?
"[#{project_link}] Issue #{state} by #{user_combined_name}" "[#{project_link}] Issue #{state} by #{user_combined_name}"
else else
"[#{project_link}] Issue #{issue_link} #{state} by #{user_combined_name}" "[#{project_link}] Issue #{issue_link} #{state} by #{user_combined_name}"

View file

@ -0,0 +1,5 @@
---
title: Include link to issue in reopen message for Slack and Mattermost notifications
merge_request:
author:
type: fixed

View file

@ -66,6 +66,19 @@ describe ChatMessage::IssueMessage do
expect(subject.attachments).to be_empty expect(subject.attachments).to be_empty
end end
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('[<http://somewhere.com|project_name>] Issue <http://url.com|#100 Issue title> opened by Test User (test.user)')
expect(subject.attachments).to be_empty
end
end
end end
context 'with markdown' do context 'with markdown' do