Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/graphql/types/group_type_spec.rb')
-rw-r--r--spec/graphql/types/group_type_spec.rb51
1 files changed, 49 insertions, 2 deletions
diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb
index 69c7eaf111f..72b3bb90194 100644
--- a/spec/graphql/types/group_type_spec.rb
+++ b/spec/graphql/types/group_type_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['Group'] do
+ include GraphqlHelpers
+
specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Group) }
specify { expect(described_class.graphql_name).to eq('Group') }
@@ -22,8 +24,8 @@ RSpec.describe GitlabSchema.types['Group'] do
dependency_proxy_blobs dependency_proxy_image_count
dependency_proxy_blob_count dependency_proxy_total_size
dependency_proxy_image_prefix dependency_proxy_image_ttl_policy
- shared_runners_setting timelogs organizations contacts work_item_types
- recent_issue_boards ci_variables
+ shared_runners_setting timelogs organizations contacts contact_state_counts
+ work_item_types recent_issue_boards ci_variables
]
expect(described_class).to include_graphql_fields(*expected_fields)
@@ -53,7 +55,52 @@ RSpec.describe GitlabSchema.types['Group'] do
end
end
+ describe 'contact_state_counts field' do
+ subject { described_class.fields['contactStateCounts'] }
+
+ it { is_expected.to have_graphql_type(Types::CustomerRelations::ContactStateCountsType) }
+ it { is_expected.to have_graphql_resolver(Resolvers::Crm::ContactStateCountsResolver) }
+ end
+
it_behaves_like 'a GraphQL type with labels' do
let(:labels_resolver_arguments) { [:search_term, :includeAncestorGroups, :includeDescendantGroups, :onlyGroupLabels] }
end
+
+ describe 'milestones' do
+ let(:user) { create(:user) }
+ let(:subgroup) { create(:group, parent: create(:group)) }
+ let(:query) do
+ %(
+ query {
+ group(fullPath: "#{subgroup.full_path}") {
+ milestones {
+ nodes {
+ id
+ title
+ projectMilestone
+ groupMilestone
+ subgroupMilestone
+ }
+ }
+ }
+ }
+ )
+ end
+
+ def clean_state_query
+ run_with_clean_state(query, context: { current_user: user })
+ end
+
+ it 'avoids N+1 queries' do
+ subgroup.add_reporter(user)
+
+ create(:milestone, group: subgroup)
+
+ control = ActiveRecord::QueryRecorder.new(skip_cached: false) { clean_state_query }
+
+ create_list(:milestone, 2, group: subgroup)
+
+ expect { clean_state_query }.not_to exceed_all_query_limit(control)
+ end
+ end
end