Commit 8707827d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve readablity of CI_API_V4_URL related code

parent 476cba6f
...@@ -1705,9 +1705,7 @@ class Project < ActiveRecord::Base ...@@ -1705,9 +1705,7 @@ class Project < ActiveRecord::Base
def api_variables def api_variables
Gitlab::Ci::Variables::Collection.new.tap do |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: API::Helpers::Version.new('v4').root_url)
variables.append(key: 'CI_API_V4_URL', value: version.root_url)
end
end end
end end
......
...@@ -18,7 +18,7 @@ module API ...@@ -18,7 +18,7 @@ module API
end end
def root_url def root_url
@root_url ||= expose_url(root_path) @root_url ||= expose_url(root_path)
end end
def to_s def to_s
......
...@@ -20,7 +20,7 @@ describe API::Helpers::Version do ...@@ -20,7 +20,7 @@ describe API::Helpers::Version do
describe '#root_url' do describe '#root_url' do
it 'returns an URL for a root path for the API version' do it 'returns an URL for a root path for the API version' do
expect(described_class.new('v4').root_url) expect(described_class.new('v4').root_url)
.to match %r{^http?://.*/api/v4$} .to eq 'http://localhost/api/v4'
end end
end 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