diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-05-22 08:54:20 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-05-22 08:54:20 +0000 |
commit | 0af4c56cff7a78a873f6c82e0942fbb2a394e71c (patch) | |
tree | a7d32638bf9ac680c145b9baa705c4a1829af33d /spec/lib/api | |
parent | 735727618565a732a2801ff758495793c8e93eed (diff) | |
download | gitlab-ce-0af4c56cff7a78a873f6c82e0942fbb2a394e71c.tar.gz |
Fix `expose_url` helper does not include custom base url if it is set
Diffstat (limited to 'spec/lib/api')
-rw-r--r-- | spec/lib/api/helpers/related_resources_helpers_spec.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/lib/api/helpers/related_resources_helpers_spec.rb b/spec/lib/api/helpers/related_resources_helpers_spec.rb index b918301f1cb..66af7f81535 100644 --- a/spec/lib/api/helpers/related_resources_helpers_spec.rb +++ b/spec/lib/api/helpers/related_resources_helpers_spec.rb @@ -9,9 +9,9 @@ describe API::Helpers::RelatedResourcesHelpers do let(:path) { '/api/v4/awesome_endpoint' } subject(:url) { helpers.expose_url(path) } - def stub_default_url_options(protocol: 'http', host: 'example.com', port: nil) + def stub_default_url_options(protocol: 'http', host: 'example.com', port: nil, script_name: '') expect(Gitlab::Application.routes).to receive(:default_url_options) - .and_return(protocol: protocol, host: host, port: port) + .and_return(protocol: protocol, host: host, port: port, script_name: script_name) end it 'respects the protocol if it is HTTP' do @@ -37,5 +37,17 @@ describe API::Helpers::RelatedResourcesHelpers do is_expected.to start_with('http://example.com:8080/') end + + it 'includes the relative_url before the path if it is set' do + stub_default_url_options(script_name: '/gitlab') + + is_expected.to start_with('http://example.com/gitlab/api/v4') + end + + it 'includes the path after the host' do + stub_default_url_options + + is_expected.to start_with('http://example.com/api/v4') + end end end |