diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-09-22 17:01:01 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-09-22 17:01:01 +0800 |
commit | 6987ec29b084ca842e46601965a60519fe96dc33 (patch) | |
tree | 066d1c6b2094411468087a8825cb4c6ecd25f848 /spec | |
parent | 73b4eecddecf1e86d5e0c26166e2027583b680cf (diff) | |
download | gitlab-ce-6987ec29b084ca842e46601965a60519fe96dc33.tar.gz |
For empty merge_request_diff st_commits would be nilfix-pipeline-for-empty-merge-request-diff
Closes #22438
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/merge_request_spec.rb | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 433aba7747b..12df6adde44 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -517,7 +517,7 @@ describe MergeRequest, models: true do context 'with multiple irrelevant merge_request_diffs' do before do - subject.update(target_branch: 'markdown') + subject.update(target_branch: 'v1.0.0') end it_behaves_like 'returning pipelines with proper ordering' @@ -544,13 +544,28 @@ describe MergeRequest, models: true do subject.merge_request_diffs.flat_map(&:commits).map(&:sha).uniq end - before do - subject.update(target_branch: 'markdown') + shared_examples 'returning all SHA' do + 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 + + context 'with a completely different branch' do + before do + subject.update(target_branch: 'v1.0.0') + end + + it_behaves_like 'returning all SHA' 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) + context 'with a branch having no difference' do + before do + subject.update(target_branch: 'v1.1.0') + subject.reload # make sure commits were not cached + end + + it_behaves_like 'returning all SHA' end end |