diff options
author | Nick Thomas <nick@gitlab.com> | 2019-01-24 16:23:57 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-03-05 15:00:32 +0000 |
commit | 21779d00186d75349165d6c07dbe04aace68017c (patch) | |
tree | 25aaf112b51d6f5360a3e97db6f31f98a642660e /spec/requests | |
parent | 42d3117f9c3371e07e8b0aafab6f504e87251c2a (diff) | |
download | gitlab-ce-21779d00186d75349165d6c07dbe04aace68017c.tar.gz |
Add metadata about the GitLab server to GraphQL
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql/metadata_query_spec.rb | 32 | ||||
-rw-r--r-- | spec/requests/api/version_spec.rb | 18 |
2 files changed, 49 insertions, 1 deletions
diff --git a/spec/requests/api/graphql/metadata_query_spec.rb b/spec/requests/api/graphql/metadata_query_spec.rb new file mode 100644 index 00000000000..4c56c559cf9 --- /dev/null +++ b/spec/requests/api/graphql/metadata_query_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'getting project information' do + include GraphqlHelpers + + let(:query) { graphql_query_for('metadata', {}, all_graphql_fields_for('Metadata')) } + + context 'logged in' do + it 'returns version and revision' do + post_graphql(query, current_user: create(:user)) + + expect(graphql_errors).to be_nil + expect(graphql_data).to eq( + 'metadata' => { + 'version' => Gitlab::VERSION, + 'revision' => Gitlab.revision + } + ) + end + end + + context 'anonymous user' do + it 'returns nothing' do + post_graphql(query, current_user: nil) + + expect(graphql_errors).to be_nil + expect(graphql_data).to eq('metadata' => nil) + end + end +end diff --git a/spec/requests/api/version_spec.rb b/spec/requests/api/version_spec.rb index 38b618191fb..e06f8bbc095 100644 --- a/spec/requests/api/version_spec.rb +++ b/spec/requests/api/version_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe API::Version do - describe 'GET /version' do + shared_examples_for 'GET /version' do context 'when unauthenticated' do it 'returns authentication error' do get api('/version') @@ -22,4 +22,20 @@ describe API::Version do end end end + + context 'with graphql enabled' do + before do + stub_feature_flags(graphql: true) + end + + include_examples 'GET /version' + end + + context 'with graphql disabled' do + before do + stub_feature_flags(graphql: false) + end + + include_examples 'GET /version' + end end |