blob: 67af612a4a0983716d1a4e7ca9ea31d5ae47c816 (
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
|
# frozen_string_literal: true
require 'spec_helper'
describe 'getting a repository in a project' do
include GraphqlHelpers
let(:project) { create(:project, :repository) }
let(:current_user) { project.owner }
let(:fields) do
<<~QUERY
#{all_graphql_fields_for('repository'.classify)}
QUERY
end
let(:query) do
graphql_query_for(
'project',
{ 'fullPath' => project.full_path },
query_graphql_field('repository', {}, fields)
)
end
it 'returns repository' do
post_graphql(query, current_user: current_user)
expect(graphql_data['project']['repository']).to be_present
end
context 'as a non-authorized user' do
let(:current_user) { create(:user) }
it 'returns nil' do
post_graphql(query, current_user: current_user)
expect(graphql_data['project']).to be(nil)
end
end
end
|