Commit 179a1ee7 authored by lulalala's avatar lulalala Committed by Mark Chao

Add MergeRequest#merge_participants

For notifying via todo or email.
parent 75171053
...@@ -333,6 +333,16 @@ class MergeRequest < ActiveRecord::Base ...@@ -333,6 +333,16 @@ class MergeRequest < ActiveRecord::Base
update_column(:merge_jid, jid) update_column(:merge_jid, jid)
end end
def merge_participants
participants = [author]
if merge_when_pipeline_succeeds? && !participants.include?(merge_user)
participants << merge_user
end
participants
end
def first_commit def first_commit
merge_request_diff ? merge_request_diff.first_commit : compare_commits.first merge_request_diff ? merge_request_diff.first_commit : compare_commits.first
end end
......
...@@ -2242,4 +2242,39 @@ describe MergeRequest do ...@@ -2242,4 +2242,39 @@ describe MergeRequest do
expect(merge_request.can_allow_maintainer_to_push?(user)).to be_truthy expect(merge_request.can_allow_maintainer_to_push?(user)).to be_truthy
end end
end end
describe '#merge_participants' do
it 'contains author' do
expect(subject.merge_participants).to eq([subject.author])
end
describe 'when merge_when_pipeline_succeeds? is true' do
describe 'when merge user is author' do
let(:user) { create(:user) }
subject do
create(:merge_request,
merge_when_pipeline_succeeds: true,
merge_user: user,
author: user)
end
it 'contains author only' do
expect(subject.merge_participants).to eq([subject.author])
end
end
describe 'when merge user and author are different users' do
let(:merge_user) { create(:user) }
subject do
create(:merge_request,
merge_when_pipeline_succeeds: true,
merge_user: merge_user)
end
it 'contains author and merge user' do
expect(subject.merge_participants).to eq([subject.author, merge_user])
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