Commit d5cfc015 authored by Timothy Jones's avatar Timothy Jones

Handle all approval messages in merge chat message

parent b4f8e281
...@@ -18,7 +18,16 @@ module EE ...@@ -18,7 +18,16 @@ module EE
override :state_or_action_text override :state_or_action_text
def state_or_action_text def state_or_action_text
action == 'approved' ? action : super case action
when 'approved', 'unapproved'
action
when 'approval'
'added their approval to'
when 'unapproval'
'removed their approval from'
else
super
end
end end
end end
end end
......
---
title: Add support for partial approval in chat message merge request event handler
merge_request:
author:
type: fixed
...@@ -27,16 +27,55 @@ RSpec.describe ChatMessage::MergeMessage do ...@@ -27,16 +27,55 @@ RSpec.describe ChatMessage::MergeMessage do
} }
end end
context 'approval' do context 'approved' do
before do before do
args[:object_attributes][:action] = 'approved' args[:object_attributes][:action] = 'approved'
end end
it 'returns a message regarding approval of merge requests' do it 'returns a message regarding completed approval of merge requests' do
expect(subject.pretext).to eq( expect(subject.pretext).to eq(
'Test User (test.user) approved <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> '\ 'Test User (test.user) approved <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> '\
'in <http://somewhere.com|project_name>') 'in <http://somewhere.com|project_name>')
expect(subject.attachments).to be_empty expect(subject.attachments).to be_empty
end end
end end
context 'unapproved' do
before do
args[:object_attributes][:action] = 'unapproved'
end
it 'returns a message regarding revocation of completed approval of merge requests' do
expect(subject.pretext).to eq(
'Test User (test.user) unapproved <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> '\
'in <http://somewhere.com|project_name>')
expect(subject.attachments).to be_empty
end
end
context 'approval' do
before do
args[:object_attributes][:action] = 'approval'
end
it 'returns a message regarding added approval of merge requests' do
expect(subject.pretext).to eq(
'Test User (test.user) added their approval to <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> '\
'in <http://somewhere.com|project_name>')
expect(subject.attachments).to be_empty
end
end
context 'unapproval' do
before do
args[:object_attributes][:action] = 'unapproval'
end
it 'returns a message regarding revoking approval of merge requests' do
expect(subject.pretext).to eq(
'Test User (test.user) removed their approval from <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> '\
'in <http://somewhere.com|project_name>')
expect(subject.attachments).to be_empty
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