diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-01-04 15:32:40 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-01-04 15:32:40 +0100 |
commit | 8707827d3925441a838ba425e65dfdb8d3845a31 (patch) | |
tree | b7ba6494bd1b421530d83713666f81636f001eab | |
parent | 476cba6ff355197ca7137af1fcab74a7d6c776ad (diff) | |
download | gitlab-ce-8707827d3925441a838ba425e65dfdb8d3845a31.tar.gz |
Improve readablity of CI_API_V4_URL related code
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | lib/api/helpers/version.rb | 2 | ||||
-rw-r--r-- | spec/lib/api/helpers/version_spec.rb | 2 |
3 files changed, 3 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index d829d976afc..1109cb4383f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/lib/api/helpers/version.rb b/lib/api/helpers/version.rb index a322d99e9aa..7f53094e90c 100644 --- a/lib/api/helpers/version.rb +++ b/lib/api/helpers/version.rb @@ -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 diff --git a/spec/lib/api/helpers/version_spec.rb b/spec/lib/api/helpers/version_spec.rb index 63e7e1e6e95..34006e0930b 100644 --- a/spec/lib/api/helpers/version_spec.rb +++ b/spec/lib/api/helpers/version_spec.rb @@ -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 |