Commit 55de6e15 authored by Lin Jen-Shin's avatar Lin Jen-Shin

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
parent f2eb10c9
...@@ -496,20 +496,18 @@ describe MergeRequest, models: true do ...@@ -496,20 +496,18 @@ describe MergeRequest, models: true do
describe '#all_pipelines' do describe '#all_pipelines' do
shared_examples 'returning pipelines with proper ordering' do shared_examples 'returning pipelines with proper ordering' do
let!(:pipelines) do let!(:all_pipelines) do
subject.merge_request_diffs.flat_map do |diff| subject.all_commits_sha.map do |sha|
diff.commits.map do |commit| create(:ci_empty_pipeline,
create(:ci_empty_pipeline, project: subject.source_project,
project: subject.source_project, sha: sha,
sha: commit.id, ref: subject.source_branch)
ref: subject.source_branch)
end
end end
end end
it 'returns all pipelines' do it 'returns all pipelines' do
expect(subject.all_pipelines).not_to be_empty 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
end end
...@@ -526,6 +524,21 @@ describe MergeRequest, models: true do ...@@ -526,6 +524,21 @@ describe MergeRequest, models: true do
end end
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 describe '#participants' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment