Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_query_spec.rb « graphql « api « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8196bcfa87c43f51fa08aa1850f62837abc96b83 (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
34
35
36
37
38
39
require 'spec_helper'

describe 'getting project information' do
  include GraphqlHelpers

  let(:project) { create(:project, :repository) }
  let(:current_user) { create(:user) }

  let(:query) do
    graphql_query_for('project', 'fullPath' => project.full_path)
  end

  context 'when the user has access to the project' do
    before do
      project.add_developer(current_user)
      post_graphql(query, current_user: current_user)
    end

    it 'includes the project' do
      expect(graphql_data['project']).not_to be_nil
    end

    it_behaves_like 'a working graphql query'
  end

  context 'when the user does not have access to the project' do
    before do
      post_graphql(query, current_user: current_user)
    end

    it 'returns an empty field' do
      post_graphql(query, current_user: current_user)

      expect(graphql_data['project']).to be_nil
    end

    it_behaves_like 'a working graphql query'
  end
end