diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-20 15:07:56 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-09-20 15:07:56 +0300 |
commit | 55de6e15d3b29c89a137e3e8824f02ddc4b7c1e7 (patch) | |
tree | 9d8652ee1eb44ae4f0ead2c3f246ed13826715fb /spec | |
parent | f2eb10c9bc6428c532f79914b737082518fae7e8 (diff) |
Test against MergeRequest#all_commits_sha, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6414#note_15750344
So that we could just use it in testing for MergeRequest#all_pipelines
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/merge_request_spec.rb | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index fb599e1207d..5baed2946e5 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -496,20 +496,18 @@ describe MergeRequest, models: true do describe '#all_pipelines' do shared_examples 'returning pipelines with proper ordering' do - let!(:pipelines) do - subject.merge_request_diffs.flat_map do |diff| - diff.commits.map do |commit| - create(:ci_empty_pipeline, - project: subject.source_project, - sha: commit.id, - ref: subject.source_branch) - end + let!(:all_pipelines) do + subject.all_commits_sha.map do |sha| + create(:ci_empty_pipeline, + project: subject.source_project, + sha: sha, + ref: subject.source_branch) end end it 'returns all pipelines' do expect(subject.all_pipelines).not_to be_empty - expect(subject.all_pipelines).to eq(pipelines.reverse) + expect(subject.all_pipelines).to eq(all_pipelines.reverse) end end @@ -526,6 +524,21 @@ describe MergeRequest, models: true do end end + describe '#all_commits_sha' do + let(:all_commits_sha) do + subject.merge_request_diffs.flat_map(&:commits).map(&:sha).uniq + end + + before do + subject.update(target_branch: 'markdown') + end + + it 'returns all SHA from all merge_request_diffs' do + expect(subject.merge_request_diffs.size).to eq(2) + expect(subject.all_commits_sha).to eq(all_commits_sha) + end + end + describe '#participants' do let(:project) { create(:project, :public) } |