summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql/current_user_query_spec.rb
blob: 2b38b8e98ab6155d09310cd6f497c576b9ed9538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'spec_helper'

describe 'getting project information' do
  include GraphqlHelpers

  let(:query) do
    graphql_query_for('currentUser', {}, 'name')
  end

  subject { graphql_data['currentUser'] }

  before do
    post_graphql(query, current_user: current_user)
  end

  context 'when there is a current_user' do
    let_it_be(:current_user) { create(:user) }

    it_behaves_like 'a working graphql query'

    it { is_expected.to include('name' => current_user.name) }
  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