diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2019-01-03 10:59:14 +0000 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2019-01-08 00:27:29 +0100 |
commit | a2842241d4f583625053aba4d2c37a2f15b21913 (patch) | |
tree | 088aeb8c89c56e20ea5f003e3556584b5b524232 /spec/models/merge_request_spec.rb | |
parent | cfa7108210490704a8110ee97a26de9ae4d9adaf (diff) | |
download | gitlab-ce-a2842241d4f583625053aba4d2c37a2f15b21913.tar.gz |
Add committers and authors methods on MergeRequest
These are used by the EE-only approvers feature
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 96d49e86dab..e18b29df321 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -991,6 +991,34 @@ describe MergeRequest do end end + describe '#committers' do + it 'returns all the committers of every commit in the merge request' do + users = subject.commits.map(&:committer_email).uniq.map do |email| + create(:user, email: email) + end + + expect(subject.committers).to match_array(users) + end + + it 'returns an empty array if no committer is associated with a user' do + expect(subject.committers).to be_empty + end + end + + describe '#authors' do + it 'returns a list with all the committers in the merge request and author' do + users = subject.commits.map(&:committer_email).uniq.map do |email| + create(:user, email: email) + end + + expect(subject.authors).to match_array([subject.author, *users]) + end + + it 'returns only the author if no committer is associated with a user' do + expect(subject.authors).to contain_exactly(subject.author) + end + end + describe '#hook_attrs' do it 'delegates to Gitlab::HookData::MergeRequestBuilder#build' do builder = double |