diff options
Diffstat (limited to 'spec/requests/api/graphql/metadata_query_spec.rb')
-rw-r--r-- | spec/requests/api/graphql/metadata_query_spec.rb | 32 |
1 files changed, 32 insertions, 0 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 |