summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2019-03-19 13:58:08 +0300
committerIgor Drozdov <idrozdov@gitlab.com>2019-03-19 14:00:05 +0300
commitade207e575ab846f6d354aaccc1382a6e512dd0d (patch)
tree6cbb8f04284211ab7a811e9cbfc610ee69be5950
parentb53376592491cf2016fe68fecaf5f090cf4627b4 (diff)
downloadgitlab-ce-ade207e575ab846f6d354aaccc1382a6e512dd0d.tar.gz
Backport splitting approval changes from CE
Author and committers approvals are split in EE This commit provides backports for those changes This reverts commit 886f00bcba23d67e2c86591c2eb5359ef457a2f9.
-rw-r--r--app/models/commit_collection.rb4
-rw-r--r--app/models/merge_request.rb8
-rw-r--r--spec/models/commit_collection_spec.rb14
-rw-r--r--spec/models/merge_request_spec.rb27
4 files changed, 17 insertions, 36 deletions
diff --git a/app/models/commit_collection.rb b/app/models/commit_collection.rb
index a9a2e9c81eb..42ec5b5e664 100644
--- a/app/models/commit_collection.rb
+++ b/app/models/commit_collection.rb
@@ -20,8 +20,8 @@ class CommitCollection
commits.each(&block)
end
- def authors
- emails = without_merge_commits.map(&:author_email).uniq
+ def committers
+ emails = without_merge_commits.map(&:committer_email).uniq
User.by_any_email(emails)
end
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index aeb6acf0ac0..ea9c29daafc 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -312,12 +312,8 @@ class MergeRequest < ActiveRecord::Base
work_in_progress?(title) ? title : "WIP: #{title}"
end
- def commit_authors
- @commit_authors ||= commits.authors
- end
-
- def authors
- User.from_union([commit_authors, User.where(id: self.author_id)])
+ def committers
+ @committers ||= commits.committers
end
# Verifies if title has changed not taking into account WIP prefix
diff --git a/spec/models/commit_collection_spec.rb b/spec/models/commit_collection_spec.rb
index 0f5d03ff458..12e59b35428 100644
--- a/spec/models/commit_collection_spec.rb
+++ b/spec/models/commit_collection_spec.rb
@@ -12,26 +12,26 @@ describe CommitCollection do
end
end
- describe '.authors' do
+ describe '.committers' do
it 'returns a relation of users when users are found' do
- user = create(:user, email: commit.author_email.upcase)
+ user = create(:user, email: commit.committer_email.upcase)
collection = described_class.new(project, [commit])
- expect(collection.authors).to contain_exactly(user)
+ expect(collection.committers).to contain_exactly(user)
end
- it 'returns empty array when authors cannot be found' do
+ it 'returns empty array when committers cannot be found' do
collection = described_class.new(project, [commit])
- expect(collection.authors).to be_empty
+ expect(collection.committers).to be_empty
end
it 'excludes authors of merge commits' do
commit = project.commit("60ecb67744cb56576c30214ff52294f8ce2def98")
- create(:user, email: commit.author_email.upcase)
+ create(:user, email: commit.committer_email.upcase)
collection = described_class.new(project, [commit])
- expect(collection.authors).to be_empty
+ expect(collection.committers).to be_empty
end
end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 42c49e330cc..c3f87edb0c6 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -454,7 +454,6 @@ describe MergeRequest do
it 'does not cache issues from external trackers' do
issue = ExternalIssue.new('JIRA-123', subject.project)
commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
-
allow(subject).to receive(:commits).and_return([commit])
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to raise_error
@@ -1043,31 +1042,17 @@ describe MergeRequest do
end
end
- describe '#commit_authors' do
- it 'returns all the authors of every commit in the merge request' do
- users = subject.commits.map(&:author_email).uniq.map do |email|
- create(:user, email: email)
- end
-
- expect(subject.commit_authors).to match_array(users)
- end
-
- it 'returns an empty array if no author is associated with a user' do
- expect(subject.commit_authors).to be_empty
- end
- end
-
- describe '#authors' do
- it 'returns a list with all the commit authors in the merge request and author' do
- users = subject.commits.map(&:author_email).uniq.map do |email|
+ 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.authors).to match_array([subject.author, *users])
+ expect(subject.committers).to match_array(users)
end
- it 'returns only the author if no committer is associated with a user' do
- expect(subject.authors).to contain_exactly(subject.author)
+ it 'returns an empty array if no committer is associated with a user' do
+ expect(subject.committers).to be_empty
end
end