Improve readablity of CI_API_V4_URL related code
This commit is contained in:
parent
476cba6ff3
commit
8707827d39
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue