diff options
Diffstat (limited to 'spec/controllers/projects/merge_requests/diffs_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/merge_requests/diffs_controller_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb index 65a89d890c3..88c14e03fd8 100644 --- a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb @@ -203,6 +203,41 @@ describe Projects::MergeRequests::DiffsController do end end + context 'with diff_head param passed' do + before do + allow(merge_request).to receive(:diffable_merge_ref?) + .and_return(diffable_merge_ref) + end + + context 'the merge request can be compared with head' do + let(:diffable_merge_ref) { true } + + it 'compares diffs with the head' do + MergeRequests::MergeToRefService.new(project, merge_request.author).execute(merge_request) + + expect(CompareService).to receive(:new).with( + project, merge_request.merge_ref_head.sha + ).and_call_original + + go(diff_head: true) + + expect(response).to have_gitlab_http_status(:ok) + end + end + + context 'the merge request cannot be compared with head' do + let(:diffable_merge_ref) { false } + + it 'compares diffs with the base' do + expect(CompareService).not_to receive(:new) + + go(diff_head: true) + + expect(response).to have_gitlab_http_status(:ok) + end + end + end + context 'with MR regular diff params' do it 'returns success' do go |