diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-20 23:43:10 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-20 23:43:10 +0100 |
commit | d496a6b919abd32252f54e59d5607956005cfb15 (patch) | |
tree | 128d9e5fc2ddaf8f325da2ccdef140c0647bbcea /spec/models | |
parent | 94b90db5479a4536d459d8e6beaeaea376f6b356 (diff) | |
download | gitlab-ce-d496a6b919abd32252f54e59d5607956005cfb15.tar.gz |
Handle removed source projects in MR CI commitsfix-merge-requests-without-source-projects
When calling MergeRequest#ci_commit the code would previously raise an
error if the source project no longer existed (e.g. because the user
removed their fork).
See #3599 for more information.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/merge_request_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 90af75ff0e3..567c911425c 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -193,4 +193,29 @@ describe MergeRequest do it_behaves_like 'a Taskable' do subject { create :merge_request, :simple } end + + describe '#ci_commit' do + describe 'when the source project exists' do + it 'returns the latest commit' do + commit = double(:commit, id: '123abc') + ci_commit = double(:ci_commit) + + allow(subject).to receive(:last_commit).and_return(commit) + + expect(subject.source_project).to receive(:ci_commit). + with('123abc'). + and_return(ci_commit) + + expect(subject.ci_commit).to eq(ci_commit) + end + end + + describe 'when the source project does not exist' do + it 'returns nil' do + allow(subject).to receive(:source_project).and_return(nil) + + expect(subject.ci_commit).to be_nil + end + end + end end |