diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index 0bd0f251c1a3f601aec9da51c5b6a76582fb983f..96ebdaf93706e65322fb9391fa1188c801e8c229 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -62,6 +62,11 @@ class GroupType < NamespaceType null: true, description: 'Indicates if a group has email notifications disabled.' + field :emails_enabled, + type: GraphQL::Types::Boolean, + null: true, + description: 'Indicates if a group has email notifications enabled.' + field :max_access_level, Types::AccessLevelType, null: false, description: 'The maximum access level of the current user in the group.' @@ -365,6 +370,10 @@ def descendant_groups_count end end + def emails_disabled + !group.emails_enabled? + end + def projects_count BatchLoader::GraphQL.for(object.id).batch do |group_ids, loader| projects_counts = Group.id_in(group_ids).projects_counts diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index bc7898f8a58ec88d88a741832696e2edaf82dcb7..6a5e24bb30f5a98c1c40a1223b5d3ea57104a59e 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -19482,6 +19482,7 @@ GPG signature for a signed commit. | <a id="groupdescriptionhtml"></a>`descriptionHtml` | [`String`](#string) | GitLab Flavored Markdown rendering of `description`. | | <a id="groupdora"></a>`dora` | [`Dora`](#dora) | Group's DORA metrics. | | <a id="groupemailsdisabled"></a>`emailsDisabled` | [`Boolean`](#boolean) | Indicates if a group has email notifications disabled. | +| <a id="groupemailsenabled"></a>`emailsEnabled` | [`Boolean`](#boolean) | Indicates if a group has email notifications enabled. | | <a id="groupenforcefreeusercap"></a>`enforceFreeUserCap` | [`Boolean`](#boolean) | Indicates whether the group has limited users for a free plan. | | <a id="groupepicboards"></a>`epicBoards` | [`EpicBoardConnection`](#epicboardconnection) | Find epic boards. (see [Connections](#connections)) | | <a id="groupepicsenabled"></a>`epicsEnabled` | [`Boolean`](#boolean) | Indicates if Epics are enabled for namespace. | diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 7231a1e0357dbe7019c5f3dd3b0a3b25f8e2a1f8..e3b14287d372e2dad96ccd4da4bc5b04442ced88 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -159,4 +159,82 @@ def clean_state_query end end end + + describe 'emailsDisabled' do + let_it_be(:group) { create(:group) } + + let(:query) do + %( + query { + group(fullPath: "#{group.full_path}") { + emailsDisabled + } + } + ) + end + + subject(:result) do + result = GitlabSchema.execute(query).as_json + result.dig('data', 'group', 'emailsDisabled') + end + + it 'is not a deprecated field' do + expect(described_class.fields['emailsDisabled'].deprecation).to be_nil + end + + describe 'when emails_enabled is true' do + before do + group.update!(emails_enabled: true) + end + + it { is_expected.to eq(false) } + end + + describe 'when emails_enabled is false' do + before do + group.update!(emails_enabled: false) + end + + it { is_expected.to eq(true) } + end + end + + describe 'emailsEnabled' do + let_it_be(:group) { create(:group) } + + let(:query) do + %( + query { + group(fullPath: "#{group.full_path}") { + emailsEnabled + } + } + ) + end + + subject(:result) do + result = GitlabSchema.execute(query).as_json + result.dig('data', 'group', 'emailsEnabled') + end + + it 'is not a deprecated field' do + expect(described_class.fields['emailsEnabled'].deprecation).to be_nil + end + + describe 'when emails_enabled is true' do + before do + group.update!(emails_enabled: true) + end + + it { is_expected.to eq(true) } + end + + describe 'when emails_enabled is false' do + before do + group.update!(emails_enabled: false) + end + + it { is_expected.to eq(false) } + end + end end