diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 03:09:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 03:09:07 +0300 |
commit | e144369009f3404072f7e0f969f7cded93195a01 (patch) | |
tree | d7a354e2c3c69a7ad65dc81aba8fe2ba59b0a26f /spec/serializers/merge_request_diff_entity_spec.rb | |
parent | d466ee5042520ad078fe050cb078d81dc2ebe196 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/merge_request_diff_entity_spec.rb')
-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 |