diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2019-01-03 13:59:14 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2019-01-08 02:27:29 +0300 |
commit | a2842241d4f583625053aba4d2c37a2f15b21913 (patch) | |
tree | 088aeb8c89c56e20ea5f003e3556584b5b524232 /spec/models/commit_collection_spec.rb | |
parent | cfa7108210490704a8110ee97a26de9ae4d9adaf (diff) |
Add committers and authors methods on MergeRequest
These are used by the EE-only approvers feature
Diffstat (limited to 'spec/models/commit_collection_spec.rb')
-rw-r--r-- | spec/models/commit_collection_spec.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/models/commit_collection_spec.rb b/spec/models/commit_collection_spec.rb index 066fe7d154e..005005b236b 100644 --- a/spec/models/commit_collection_spec.rb +++ b/spec/models/commit_collection_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe CommitCollection do let(:project) { create(:project, :repository) } - let(:commit) { project.commit } + let(:commit) { project.commit("c1c67abbaf91f624347bb3ae96eabe3a1b742478") } describe '#each' do it 'yields every commit' do @@ -12,6 +12,29 @@ describe CommitCollection do end end + describe '.committers' do + it 'returns a relation of users when users are found' do + user = create(:user, email: commit.committer_email.upcase) + collection = described_class.new(project, [commit]) + + expect(collection.committers).to contain_exactly(user) + end + + it 'returns empty array when committers cannot be found' do + collection = described_class.new(project, [commit]) + + expect(collection.committers).to be_empty + end + + it 'excludes authors of merge commits' do + commit = project.commit("60ecb67744cb56576c30214ff52294f8ce2def98") + create(:user, email: commit.committer_email.upcase) + collection = described_class.new(project, [commit]) + + expect(collection.committers).to be_empty + end + end + describe '#with_pipeline_status' do it 'sets the pipeline status for every commit so no additional queries are necessary' do create( |