diff options
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/merge_request_diff_entity_spec.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/serializers/merge_request_diff_entity_spec.rb b/spec/serializers/merge_request_diff_entity_spec.rb index 59ec0b22158..2e3b0d092fe 100644 --- a/spec/serializers/merge_request_diff_entity_spec.rb +++ b/spec/serializers/merge_request_diff_entity_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe MergeRequestDiffEntity do - let(:project) { create(:project, :repository) } + let_it_be(:project) { create(:project, :repository) } let(:request) { EntityRequest.new(project: project) } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } let(:merge_request_diffs) { merge_request.merge_request_diffs } @@ -36,4 +36,29 @@ describe MergeRequestDiffEntity do expect(subject[:short_commit_sha]).to eq(nil) end end + + describe '#head_version_path' do + before do + allow(merge_request).to receive(:diffable_merge_ref?) + .and_return(diffable_merge_ref) + end + + context 'merge request can be merged' do + let(:diffable_merge_ref) { true } + + it 'returns diff path with diff_head param set' do + expect(subject[:head_version_path]).to eq( + "/#{project.full_path}/-/merge_requests/#{merge_request.iid}/diffs?diff_head=true" + ) + end + end + + context 'merge request cannot be merged' do + let(:diffable_merge_ref) { false } + + it 'returns diff path with diff_head param set' do + expect(subject[:head_version_path]).to be_nil + end + end + end end |