gitlab-org--gitlab-foss/spec/requests/api/graphql/project_query_spec.rb
Bob Van Landuyt 54b56f20b7 Expose permissions on types in GraphQL
This adds a reusable way to expose permissions for a user to types in
GraphQL.
2018-06-28 13:50:17 +02:00

44 lines
1 KiB
Ruby

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)
end
it 'includes the project' do
post_graphql(query, current_user: current_user)
expect(graphql_data['project']).not_to be_nil
end
it_behaves_like 'a working graphql query' do
before do
post_graphql(query, current_user: current_user)
end
end
end
context 'when the user does not have access to the project' do
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' do
before do
post_graphql(query, current_user: current_user)
end
end
end
end