diff options
author | Stan Hu <stanhu@gmail.com> | 2019-05-07 00:28:35 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-05-07 06:16:39 -0700 |
commit | 58c09eb70941a0954fb5cd7b0c6316c698353edb (patch) | |
tree | aec474d2b38d02064e50b2eed8acd19b242954a9 /spec | |
parent | fb688545e51d87d3b145b0c7fa9adc8c6b2139b2 (diff) | |
download | gitlab-ce-58c09eb70941a0954fb5cd7b0c6316c698353edb.tar.gz |
Use a path for the related merge requests endpointsh-fix-related-merge-requests-path
Hosts using a non-standard configuration may have a different
hostname/port/scheme than what may be configured on the GitLab
server. While expose_url should generate a proper URL, there are cases
where it may not work. Since we don't need the full URL, we can use the
relative path.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61280
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/api/helpers/related_resources_helpers_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/api/helpers/related_resources_helpers_spec.rb b/spec/lib/api/helpers/related_resources_helpers_spec.rb index 66af7f81535..99fe8795d91 100644 --- a/spec/lib/api/helpers/related_resources_helpers_spec.rb +++ b/spec/lib/api/helpers/related_resources_helpers_spec.rb @@ -5,6 +5,40 @@ describe API::Helpers::RelatedResourcesHelpers do Class.new.include(described_class).new end + describe '#expose_path' do + let(:path) { '/api/v4/awesome_endpoint' } + + context 'empty relative URL root' do + before do + stub_config_setting(relative_url_root: '') + end + + it 'returns the existing path' do + expect(helpers.expose_path(path)).to eq(path) + end + end + + context 'slash relative URL root' do + before do + stub_config_setting(relative_url_root: '/') + end + + it 'returns the existing path' do + expect(helpers.expose_path(path)).to eq(path) + end + end + + context 'with relative URL root' do + before do + stub_config_setting(relative_url_root: '/gitlab/root') + end + + it 'returns the existing path' do + expect(helpers.expose_path(path)).to eq("/gitlab/root" + path) + end + end + end + describe '#expose_url' do let(:path) { '/api/v4/awesome_endpoint' } subject(:url) { helpers.expose_url(path) } |