debian-mirror-gitlab/spec/requests/api/graphql/current_user_query_spec.rb

41 lines
846 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'getting project information' do
2019-12-26 22:10:19 +05:30
include GraphqlHelpers
2021-10-27 15:23:28 +05:30
let(:fields) do
<<~GRAPHQL
name
namespace { id }
GRAPHQL
end
2019-12-26 22:10:19 +05:30
let(:query) do
2021-10-27 15:23:28 +05:30
graphql_query_for('currentUser', {}, fields)
2019-12-26 22:10:19 +05:30
end
subject { graphql_data['currentUser'] }
before do
post_graphql(query, current_user: current_user)
end
context 'when there is a current_user' do
2020-03-13 15:44:24 +05:30
let_it_be(:current_user) { create(:user) }
2019-12-26 22:10:19 +05:30
it_behaves_like 'a working graphql query'
2021-10-27 15:23:28 +05:30
it { is_expected.to include('name' => current_user.name, 'namespace' => { 'id' => current_user.namespace.to_global_id.to_s }) }
2019-12-26 22:10:19 +05:30
end
context 'when there is no current_user' do
let(:current_user) { nil }
it_behaves_like 'a working graphql query'
it { is_expected.to be_nil }
end
end