diff options
Diffstat (limited to 'spec/requests/api/graphql/group')
6 files changed, 64 insertions, 24 deletions
diff --git a/spec/requests/api/graphql/group/dependency_proxy_group_setting_spec.rb b/spec/requests/api/graphql/group/dependency_proxy_group_setting_spec.rb index de3dbc5c324..d21c3046c1a 100644 --- a/spec/requests/api/graphql/group/dependency_proxy_group_setting_spec.rb +++ b/spec/requests/api/graphql/group/dependency_proxy_group_setting_spec.rb @@ -47,14 +47,14 @@ RSpec.describe 'getting dependency proxy settings for a group' do context 'with different permissions' do where(:group_visibility, :role, :access_granted) do :private | :maintainer | true - :private | :developer | true - :private | :reporter | true - :private | :guest | true + :private | :developer | false + :private | :reporter | false + :private | :guest | false :private | :anonymous | false :public | :maintainer | true - :public | :developer | true - :public | :reporter | true - :public | :guest | true + :public | :developer | false + :public | :reporter | false + :public | :guest | false :public | :anonymous | false end diff --git a/spec/requests/api/graphql/group/dependency_proxy_image_ttl_policy_spec.rb b/spec/requests/api/graphql/group/dependency_proxy_image_ttl_policy_spec.rb index c8797d84906..40f4b082072 100644 --- a/spec/requests/api/graphql/group/dependency_proxy_image_ttl_policy_spec.rb +++ b/spec/requests/api/graphql/group/dependency_proxy_image_ttl_policy_spec.rb @@ -46,14 +46,14 @@ RSpec.describe 'getting dependency proxy image ttl policy for a group' do context 'with different permissions' do where(:group_visibility, :role, :access_granted) do :private | :maintainer | true - :private | :developer | true - :private | :reporter | true - :private | :guest | true + :private | :developer | false + :private | :reporter | false + :private | :guest | false :private | :anonymous | false :public | :maintainer | true - :public | :developer | true - :public | :reporter | true - :public | :guest | true + :public | :developer | false + :public | :reporter | false + :public | :guest | false :public | :anonymous | false end diff --git a/spec/requests/api/graphql/group/dependency_proxy_manifests_spec.rb b/spec/requests/api/graphql/group/dependency_proxy_manifests_spec.rb index 3527c8183f6..c7149c100b2 100644 --- a/spec/requests/api/graphql/group/dependency_proxy_manifests_spec.rb +++ b/spec/requests/api/graphql/group/dependency_proxy_manifests_spec.rb @@ -122,12 +122,12 @@ RSpec.describe 'getting dependency proxy manifests in a group' do let(:current_user) { owner } context 'with default sorting' do - let_it_be(:descending_manifests) { manifests.reverse.map { |manifest| global_id_of(manifest)} } + let_it_be(:descending_manifests) { manifests.reverse.map { |manifest| global_id_of(manifest) } } it_behaves_like 'sorted paginated query' do let(:sort_param) { '' } let(:first_param) { 2 } - let(:all_records) { descending_manifests } + let(:all_records) { descending_manifests.map(&:to_s) } end end diff --git a/spec/requests/api/graphql/group/group_members_spec.rb b/spec/requests/api/graphql/group/group_members_spec.rb index 78852622835..fec866486ae 100644 --- a/spec/requests/api/graphql/group/group_members_spec.rb +++ b/spec/requests/api/graphql/group/group_members_spec.rb @@ -24,8 +24,8 @@ RSpec.describe 'getting group members information' do expect(graphql_errors).to be_nil expect(graphql_data_at(:group, :group_members, :edges, :node)).to contain_exactly( - { 'user' => { 'id' => global_id_of(user_1) } }, - { 'user' => { 'id' => global_id_of(user_2) } }, + { 'user' => a_graphql_entity_for(user_1) }, + { 'user' => a_graphql_entity_for(user_2) }, 'user' => nil ) end @@ -77,6 +77,48 @@ RSpec.describe 'getting group members information' do end end + context 'by access levels' do + before do + parent_group.add_owner(user_1) + parent_group.add_maintainer(user_2) + end + + subject(:by_access_levels) { fetch_members(group: parent_group, args: { access_levels: access_levels }) } + + context 'by owner' do + let(:access_levels) { :OWNER } + + it 'returns owner' do + by_access_levels + + expect(graphql_errors).to be_nil + expect_array_response(user_1) + end + end + + context 'by maintainer' do + let(:access_levels) { :MAINTAINER } + + it 'returns maintainer' do + by_access_levels + + expect(graphql_errors).to be_nil + expect_array_response(user_2) + end + end + + context 'by owner and maintainer' do + let(:access_levels) { [:OWNER, :MAINTAINER] } + + it 'returns owner and maintainer' do + by_access_levels + + expect(graphql_errors).to be_nil + expect_array_response(user_1, user_2) + end + end + end + context 'member relations' do let_it_be(:child_group) { create(:group, :public, parent: parent_group) } let_it_be(:grandchild_group) { create(:group, :public, parent: child_group) } @@ -182,8 +224,8 @@ RSpec.describe 'getting group members information' do def expect_array_response(*items) expect(response).to have_gitlab_http_status(:success) - member_gids = graphql_data_at(:group, :group_members, :edges, :node, :user, :id) + members = graphql_data_at(:group, :group_members, :edges, :node, :user) - expect(member_gids).to match_array(items.map { |u| global_id_of(u) }) + expect(members).to match_array(items.map { |u| a_graphql_entity_for(u) }) end end diff --git a/spec/requests/api/graphql/group/merge_requests_spec.rb b/spec/requests/api/graphql/group/merge_requests_spec.rb index c0faff11c8d..434b0d16569 100644 --- a/spec/requests/api/graphql/group/merge_requests_spec.rb +++ b/spec/requests/api/graphql/group/merge_requests_spec.rb @@ -39,7 +39,7 @@ RSpec.describe 'Query.group.mergeRequests' do end def expected_mrs(mrs) - mrs.map { |mr| a_hash_including('id' => global_id_of(mr)) } + mrs.map { |mr| a_graphql_entity_for(mr) } end describe 'not passing any arguments' do diff --git a/spec/requests/api/graphql/group/milestones_spec.rb b/spec/requests/api/graphql/group/milestones_spec.rb index 2b80b5239c8..7c51409f907 100644 --- a/spec/requests/api/graphql/group/milestones_spec.rb +++ b/spec/requests/api/graphql/group/milestones_spec.rb @@ -170,10 +170,8 @@ RSpec.describe 'Milestones through GroupQuery' do end it 'returns correct values for scalar fields' do - expect(post_query).to eq({ - 'id' => global_id_of(milestone), - 'title' => milestone.title, - 'description' => milestone.description, + expect(post_query).to match a_graphql_entity_for( + milestone, :title, :description, 'state' => 'active', 'webPath' => milestone_path(milestone), 'dueDate' => milestone.due_date.iso8601, @@ -183,7 +181,7 @@ RSpec.describe 'Milestones through GroupQuery' do 'projectMilestone' => false, 'groupMilestone' => true, 'subgroupMilestone' => false - }) + ) end context 'milestone statistics' do |