Commit 0587322e authored by Hiroyuki Sato's avatar Hiroyuki Sato

Fix license app with relative url

parent 0b65725f
......@@ -112,9 +112,18 @@ module LicenseHelper
def license_app_data
{ data: { current_active_user_count: current_active_user_count,
licenses_path: api_v4_licenses_path, delete_license_path: api_v4_license_path(id: ':id'),
licenses_path: api_licenses_url,
delete_license_path: api_license_url(id: ':id'),
new_license_path: new_admin_license_path, download_license_path: download_admin_license_path } }
end
def api_licenses_url
expose_url(api_v4_licenses_path)
end
def api_license_url(args)
expose_url(api_v4_license_path(args))
end
extend self
end
---
title: Fix error retrieving licenses when relative URL in use
merge_request: 11717
author: Hiroyuki Sato
type: fixed
require 'spec_helper'
describe LicenseHelper do
def stub_default_url_options(host: "localhost", protocol: "http", port: nil, script_name: '')
url_options = { host: host, protocol: protocol, port: port, script_name: script_name }
allow(Rails.application.routes).to receive(:default_url_options).and_return(url_options)
end
describe '#license_message' do
context 'no license installed' do
before do
......@@ -23,4 +28,32 @@ describe LicenseHelper do
end
end
end
describe '#api_licenses_url' do
it 'returns licenses API url' do
stub_default_url_options
expect(api_licenses_url).to eq('http://localhost/api/v4/licenses')
end
it 'returns licenses API url with relative url' do
stub_default_url_options(script_name: '/gitlab')
expect(api_licenses_url).to eq('http://localhost/gitlab/api/v4/licenses')
end
end
describe '#api_license_url' do
it 'returns license API url' do
stub_default_url_options
expect(api_license_url(id: 1)).to eq('http://localhost/api/v4/license/1')
end
it 'returns license API url with relative url' do
stub_default_url_options(script_name: '/gitlab')
expect(api_license_url(id: 1)).to eq('http://localhost/gitlab/api/v4/license/1')
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment