diff options
author | Douwe Maan <douwe@gitlab.com> | 2019-01-04 20:29:01 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-01-04 20:29:01 +0300 |
commit | 303f049358645312c6f77d08750e489475494201 (patch) | |
tree | 1a0a80849d9c711dac76b0344b37d17146029be5 /spec/lib | |
parent | d85e04e45247a64c704a44a2c8abecba94972061 (diff) | |
parent | 8707827d3925441a838ba425e65dfdb8d3845a31 (diff) |
Merge branch 'feature/gb/expose-ci-api-url-variable' into 'master'
Expose `CI_API_V4_URL` CI/CD variable
Closes #54621
See merge request gitlab-org/gitlab-ce!23936
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/api/api_spec.rb | 21 | ||||
-rw-r--r-- | spec/lib/api/helpers/version_spec.rb | 26 |
2 files changed, 47 insertions, 0 deletions
diff --git a/spec/lib/api/api_spec.rb b/spec/lib/api/api_spec.rb new file mode 100644 index 00000000000..ceef0b41e59 --- /dev/null +++ b/spec/lib/api/api_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe API::API do + describe '.prefix' do + it 'has a prefix defined' do + expect(described_class.prefix).to eq :api + end + end + + describe '.version' do + it 'uses most recent version of the API' do + expect(described_class.version).to eq 'v4' + end + end + + describe '.versions' do + it 'returns all available versions' do + expect(described_class.versions).to eq %w[v3 v4] + end + end +end diff --git a/spec/lib/api/helpers/version_spec.rb b/spec/lib/api/helpers/version_spec.rb new file mode 100644 index 00000000000..34006e0930b --- /dev/null +++ b/spec/lib/api/helpers/version_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe API::Helpers::Version do + describe '.new' do + it 'is possible to initialize it with existing API version' do + expect(described_class.new('v4').to_s).to eq 'v4' + end + + it 'raises an error when unsupported API version is provided' do + expect { described_class.new('v111') }.to raise_error ArgumentError + end + end + + describe '#root_path' do + it 'returns a root path of the API version' do + expect(described_class.new('v4').root_path).to eq '/api/v4' + end + end + + 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 eq 'http://localhost/api/v4' + end + end +end |