blob: 4a97e0921412a50d8e79d42c96f00bbd1a131d31 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Common::Graphql::GetMembersQuery, feature_category: :importers do
let(:entity) { create(:bulk_import_entity, :group_entity) }
let(:tracker) { create(:bulk_import_tracker, entity: entity) }
let(:context) { BulkImports::Pipeline::Context.new(tracker) }
subject(:query) { described_class.new(context: context) }
it 'has a valid query' do
parsed_query = GraphQL::Query.new(
GitlabSchema,
query.to_s,
variables: query.variables
)
result = GitlabSchema.static_validator.validate(parsed_query)
expect(result[:errors]).to be_empty
end
describe '#data_path' do
it 'returns data path' do
expected = %w[data portable members nodes]
expect(query.data_path).to eq(expected)
end
end
describe '#page_info_path' do
it 'returns pagination information path' do
expected = %w[data portable members page_info]
expect(query.page_info_path).to eq(expected)
end
end
describe '#to_s' do
context 'when entity is group' do
it 'queries group & group members' do
expect(query.to_s).to include('group')
expect(query.to_s).to include('groupMembers')
expect(query.to_s).to include('DIRECT INHERITED')
end
context "when source version is past 14.7.0" do
before do
entity.bulk_import.update!(source_version: "14.8.0")
end
it 'includes SHARED_FROM_GROUPS' do
expect(query.to_s).to include('DIRECT INHERITED SHARED_FROM_GROUPS')
end
end
end
context 'when entity is project' do
let(:entity) { create(:bulk_import_entity, :project_entity) }
it 'queries project & project members' do
expect(query.to_s).to include('project')
expect(query.to_s).to include('projectMembers')
expect(query.to_s).to include('DIRECT INHERITED INVITED_GROUPS')
end
context "when source version is at least 16.0.0" do
before do
entity.bulk_import.update!(source_version: "16.0.0")
end
it 'includes SHARED_INTO_ANCESTORS' do
expect(query.to_s).to include('DIRECT INHERITED INVITED_GROUPS SHARED_INTO_ANCESTORS')
end
end
end
end
end
|