diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-17 21:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-17 21:09:01 +0300 |
commit | e388691e4a5b5b69be903c7eceb606b853719cd5 (patch) | |
tree | 97875b98a9a9c7b0dfe9245ce70d5e38ac3a3549 /spec/graphql | |
parent | cb840235d7fb4001dab266c614bd2cf59036fe18 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/resolvers/group_milestones_resolver_spec.rb | 51 | ||||
-rw-r--r-- | spec/graphql/types/ci/job_type_spec.rb | 2 |
2 files changed, 53 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/group_milestones_resolver_spec.rb b/spec/graphql/resolvers/group_milestones_resolver_spec.rb index d8ff8e9c1f2..dd3f1676538 100644 --- a/spec/graphql/resolvers/group_milestones_resolver_spec.rb +++ b/spec/graphql/resolvers/group_milestones_resolver_spec.rb @@ -136,5 +136,56 @@ RSpec.describe Resolvers::GroupMilestonesResolver do expect(resolve_group_milestones(args)).to match_array([milestone1, milestone2, milestone3]) end end + + describe 'include_descendants and include_ancestors' do + let_it_be(:parent_group) { create(:group, :public) } + let_it_be(:group) { create(:group, :public, parent: parent_group) } + let_it_be(:accessible_group) { create(:group, :private, parent: group) } + let_it_be(:accessible_project) { create(:project, group: accessible_group) } + let_it_be(:inaccessible_group) { create(:group, :private, parent: group) } + let_it_be(:inaccessible_project) { create(:project, :private, group: group) } + let_it_be(:milestone1) { create(:milestone, group: group) } + let_it_be(:milestone2) { create(:milestone, group: accessible_group) } + let_it_be(:milestone3) { create(:milestone, project: accessible_project) } + let_it_be(:milestone4) { create(:milestone, group: inaccessible_group) } + let_it_be(:milestone5) { create(:milestone, project: inaccessible_project) } + let_it_be(:milestone6) { create(:milestone, group: parent_group) } + + before do + accessible_group.add_developer(current_user) + end + + context 'when including neither ancestor or descendant milestones in a public group' do + let(:args) { {} } + + it 'finds milestones only in accessible projects and groups' do + expect(resolve_group_milestones(args)).to match_array([milestone1]) + end + end + + context 'when including descendant milestones in a public group' do + let(:args) { { include_descendants: true } } + + it 'finds milestones only in accessible projects and groups' do + expect(resolve_group_milestones(args)).to match_array([milestone1, milestone2, milestone3]) + end + end + + context 'when including ancestor milestones in a public group' do + let(:args) { { include_ancestors: true } } + + it 'finds milestones only in accessible projects and groups' do + expect(resolve_group_milestones(args)).to match_array([milestone1, milestone6]) + end + end + + context 'when including both ancestor or descendant milestones in a public group' do + let(:args) { { include_descendants: true, include_ancestors: true } } + + it 'finds milestones only in accessible projects and groups' do + expect(resolve_group_milestones(args)).to match_array([milestone1, milestone2, milestone3, milestone6]) + end + end + end end end diff --git a/spec/graphql/types/ci/job_type_spec.rb b/spec/graphql/types/ci/job_type_spec.rb index 25f626cea0f..c54137a1c3e 100644 --- a/spec/graphql/types/ci/job_type_spec.rb +++ b/spec/graphql/types/ci/job_type_spec.rb @@ -8,6 +8,8 @@ RSpec.describe Types::Ci::JobType do it 'exposes the expected fields' do expected_fields = %i[ + id + shortSha pipeline name needs |