diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-10-19 16:14:46 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-10-19 16:14:46 +0000 |
commit | d927336403a92d340d7e5b2d2328c5a0e029d666 (patch) | |
tree | 53089a4875c6a3599e246fe182305a5d4a186a24 /spec/models/merge_request_spec.rb | |
parent | 85fba09b67c88e50d1567f6452673a5144a68433 (diff) | |
parent | 72d84e48511fcf88b1d9efb622eb37cdff95aa1c (diff) | |
download | gitlab-ce-d927336403a92d340d7e5b2d2328c5a0e029d666.tar.gz |
Merge branch '21444-pipeliens-new-mr' into 'master'
Add pipelines tab to new MR
#### What does this MR do?
Adds pipelines tab to new MRs
#### Screenshots (if relevant)


#### What are the relevant issue numbers?
Closes #21444
See merge request !6238
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 1acc8d748af..6db5e7f7d80 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -640,32 +640,56 @@ describe MergeRequest, models: true do end describe '#all_commits_sha' do - let(:all_commits_sha) do - subject.merge_request_diffs.flat_map(&:commits).map(&:sha).uniq - end + context 'when merge request is persisted' do + let(:all_commits_sha) do + subject.merge_request_diffs.flat_map(&:commits).map(&:sha).uniq + end - 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) + 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 - end - context 'with a completely different branch' do - before do - subject.update(target_branch: 'v1.0.0') + 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_behaves_like 'returning all 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 - 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 + context 'when merge request is not persisted' do + context 'when compare commits are set in the service' do + let(:commit) { spy('commit') } + + subject do + build(:merge_request, compare_commits: [commit, commit]) + end + + it 'returns commits from compare commits temporary data' do + expect(subject.all_commits_sha).to eq [commit, commit] + end end - it_behaves_like 'returning all SHA' + context 'when compare commits are not set in the service' do + subject { build(:merge_request) } + + it 'returns array with diff head sha element only' do + expect(subject.all_commits_sha).to eq [subject.diff_head_sha] + end + end end end |