diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/url_builder_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/url_builder_spec.rb')
-rw-r--r-- | spec/lib/gitlab/url_builder_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index b359eb422d7..8e372ba795b 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -69,6 +69,27 @@ RSpec.describe Gitlab::UrlBuilder do end end + context 'when passing a compare' do + # NOTE: The Compare requires an actual repository, which isn't available + # with the `build_stubbed` strategy used by the table tests above + let_it_be(:compare) { create(:compare) } + let_it_be(:project) { compare.project } + + it 'returns the full URL' do + expect(subject.build(compare)).to eq("#{Gitlab.config.gitlab.url}/#{project.full_path}/-/compare/#{compare.base_commit_sha}...#{compare.head_commit_sha}") + end + + it 'returns only the path if only_path is given' do + expect(subject.build(compare, only_path: true)).to eq("/#{project.full_path}/-/compare/#{compare.base_commit_sha}...#{compare.head_commit_sha}") + end + + it 'returns an empty string for missing project' do + expect(compare).to receive(:project).and_return(nil) + + expect(subject.build(compare)).to eq('') + end + end + context 'when passing a commit without a project' do let(:commit) { build_stubbed(:commit) } |