Improve readablity of CI_API_V4_URL related code

This commit is contained in:
Grzegorz Bizon 2019-01-04 15:32:40 +01:00
parent 476cba6ff3
commit 8707827d39
3 changed files with 3 additions and 5 deletions

View File

@ -1705,9 +1705,7 @@ class Project < ActiveRecord::Base
def api_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
API::Helpers::Version.new('v4').tap do |version|
variables.append(key: 'CI_API_V4_URL', value: version.root_url)
end
variables.append(key: 'CI_API_V4_URL', value: API::Helpers::Version.new('v4').root_url)
end
end

View File

@ -18,7 +18,7 @@ module API
end
def root_url
@root_url ||= expose_url(root_path)
@root_url ||= expose_url(root_path)
end
def to_s

View File

@ -20,7 +20,7 @@ describe API::Helpers::Version do
describe '#root_url' do
it 'returns an URL for a root path for the API version' do
expect(described_class.new('v4').root_url)
.to match %r{^http?://.*/api/v4$}
.to eq 'http://localhost/api/v4'
end
end
end