summaryrefslogtreecommitdiff
path: root/spec/models/merge_request_spec.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-03-21 10:33:29 +0000
committerSean McGivern <sean@gitlab.com>2019-03-21 10:33:29 +0000
commita97ec84f0503b164e57e7f43b217ddfea864209f (patch)
tree739cf7435829eb1387c6d8da47df69f539b61b3f /spec/models/merge_request_spec.rb
parenta8bb2c1221e67b7a3d82c24aede072248d0f78e7 (diff)
downloadgitlab-ce-a97ec84f0503b164e57e7f43b217ddfea864209f.tar.gz
Revert "Merge branch '58805-allow-incomplete-commit-data-to-be-fetched-from-collection' into 'master'"
This reverts merge request !26144
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r--spec/models/merge_request_spec.rb37
1 files changed, 21 insertions, 16 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index fad73613989..42c49e330cc 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -84,27 +84,32 @@ describe MergeRequest do
describe '#default_squash_commit_message' do
let(:project) { subject.project }
- let(:is_multiline) { -> (c) { c.description.present? } }
- let(:multiline_commits) { subject.commits.select(&is_multiline) }
- let(:singleline_commits) { subject.commits.reject(&is_multiline) }
- it 'returns the oldest multiline commit message' do
- expect(subject.default_squash_commit_message).to eq(multiline_commits.last.message)
+ def commit_collection(commit_hashes)
+ raw_commits = commit_hashes.map { |raw| Commit.from_hash(raw, project) }
+
+ CommitCollection.new(project, raw_commits)
end
- it 'returns the merge request title if there are no multiline commits' do
- expect(subject).to receive(:commits).and_return(
- CommitCollection.new(project, singleline_commits)
- )
+ it 'returns the oldest multiline commit message' do
+ commits = commit_collection([
+ { message: 'Singleline', parent_ids: [] },
+ { message: "Second multiline\nCommit message", parent_ids: [] },
+ { message: "First multiline\nCommit message", parent_ids: [] }
+ ])
- expect(subject.default_squash_commit_message).to eq(subject.title)
+ expect(subject).to receive(:commits).and_return(commits)
+
+ expect(subject.default_squash_commit_message).to eq("First multiline\nCommit message")
end
- it 'does not return commit messages from multiline merge commits' do
- collection = CommitCollection.new(project, multiline_commits).enrich!
+ it 'returns the merge request title if there are no multiline commits' do
+ commits = commit_collection([
+ { message: 'Singleline', parent_ids: [] }
+ ])
+
+ expect(subject).to receive(:commits).and_return(commits)
- expect(collection.commits).to all( receive(:merge_commit?).and_return(true) )
- expect(subject).to receive(:commits).and_return(collection)
expect(subject.default_squash_commit_message).to eq(subject.title)
end
end
@@ -1040,7 +1045,7 @@ describe MergeRequest do
describe '#commit_authors' do
it 'returns all the authors of every commit in the merge request' do
- users = subject.commits.without_merge_commits.map(&:author_email).uniq.map do |email|
+ users = subject.commits.map(&:author_email).uniq.map do |email|
create(:user, email: email)
end
@@ -1054,7 +1059,7 @@ describe MergeRequest do
describe '#authors' do
it 'returns a list with all the commit authors in the merge request and author' do
- users = subject.commits.without_merge_commits.map(&:author_email).uniq.map do |email|
+ users = subject.commits.map(&:author_email).uniq.map do |email|
create(:user, email: email)
end