diff --git a/app/assets/javascripts/boards/constants.js b/app/assets/javascripts/boards/constants.js index 84564560fe332124e828ee3f2c7cb061236697f1..5fdac79e5cd8600f4cad16eac5ef78f0c7743a1c 100644 --- a/app/assets/javascripts/boards/constants.js +++ b/app/assets/javascripts/boards/constants.js @@ -123,7 +123,7 @@ export const listIssuablesQueries = { confidential: false, closedAt: null, dueDate: null, - emailsDisabled: false, + emailsEnabled: true, hidden: false, humanTimeEstimate: null, humanTotalTimeSpent: null, diff --git a/app/assets/javascripts/boards/index.js b/app/assets/javascripts/boards/index.js index 0d8882cf57e09772a5232f62f9b8dece4442f1db..6f9a587b0c9e1f840b2f354f46a73448f06c320d 100644 --- a/app/assets/javascripts/boards/index.js +++ b/app/assets/javascripts/boards/index.js @@ -55,7 +55,7 @@ function mountBoardApp(el) { releasesFetchPath: el.dataset.releasesFetchPath, timeTrackingLimitToHours: parseBoolean(el.dataset.timeTrackingLimitToHours), issuableType: TYPE_ISSUE, - emailsDisabled: parseBoolean(el.dataset.emailsDisabled), + emailsEnabled: parseBoolean(el.dataset.emailsEnabled), hasMissingBoards: parseBoolean(el.dataset.hasMissingBoards), weights: el.dataset.weights ? JSON.parse(el.dataset.weights) : [], isIssueBoard: true, diff --git a/app/assets/javascripts/sidebar/components/subscriptions/subscriptions.vue b/app/assets/javascripts/sidebar/components/subscriptions/subscriptions.vue index b13f594603b797abde51dfa93f78b7b086e24391..3245f49a298eef8f6341783802b3d07bc7611c99 100644 --- a/app/assets/javascripts/sidebar/components/subscriptions/subscriptions.vue +++ b/app/assets/javascripts/sidebar/components/subscriptions/subscriptions.vue @@ -25,10 +25,10 @@ export default { required: false, default: false, }, - projectEmailsDisabled: { + projectEmailsEnabled: { type: Boolean, required: false, - default: false, + default: true, }, subscribeDisabledDescription: { type: String, @@ -57,19 +57,19 @@ export default { return this.subscribed === null; }, notificationIcon() { - if (this.projectEmailsDisabled) { + if (!this.projectEmailsEnabled) { return ICON_OFF; } return this.subscribed ? ICON_ON : ICON_OFF; }, notificationTooltip() { - if (this.projectEmailsDisabled) { + if (!this.projectEmailsEnabled) { return this.subscribeDisabledDescription; } return this.subscribed ? LABEL_ON : LABEL_OFF; }, notificationText() { - if (this.projectEmailsDisabled) { + if (!this.projectEmailsEnabled) { return this.subscribeDisabledDescription; } return __('Notifications'); @@ -118,7 +118,7 @@ export default { </span> <span class="hide-collapsed" data-testid="subscription-title"> {{ notificationText }} </span> <gl-toggle - v-if="!projectEmailsDisabled" + v-if="projectEmailsEnabled" :is-loading="showLoadingState" :value="subscribed" class="hide-collapsed" diff --git a/app/assets/javascripts/sidebar/stores/sidebar_store.js b/app/assets/javascripts/sidebar/stores/sidebar_store.js index ea3b3633ea76715a097b64311a6bd223fdee2fcf..05bd374ae7bd7e21e9be4b814473a57aa2fdafdd 100644 --- a/app/assets/javascripts/sidebar/stores/sidebar_store.js +++ b/app/assets/javascripts/sidebar/stores/sidebar_store.js @@ -31,7 +31,7 @@ export default class SidebarStore { this.moveToProjectId = 0; this.isLockDialogOpen = false; this.participants = []; - this.projectEmailsDisabled = false; + this.projectEmailsEnabled = true; this.subscribeDisabledDescription = ''; this.subscribed = null; this.changing = false; diff --git a/app/models/group.rb b/app/models/group.rb index d8e3e8274d107d097524d89cd9b4d181cf76cfb3..264fe57abfb21750400ffc4156d2b481262095eb 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -350,7 +350,6 @@ def preset_root_ancestor_for(groups) # column is set to false anywhere in the ancestor hierarchy. def ids_with_disabled_email(groups) inner_groups = Group.where('id = namespaces_with_emails_disabled.id') - inner_query = inner_groups .self_and_ancestors .joins(:namespace_settings) diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 511f03517adbe141b409fba53380b4fb2825adfc..4c2b799cba06a281c776313ef4c7d95bb46641c0 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -25,6 +25,8 @@ class Namespace < ApplicationRecord cross_database_ignore_tables %w[routes redirect_routes], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424277' + ignore_column :emails_disabled, remove_with: '17.0', remove_after: '2024-04-24' + # Tells ActiveRecord not to store the full class name, in order to save some space # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69794 self.store_full_sti_class = false @@ -166,7 +168,6 @@ class Namespace < ApplicationRecord :lock_math_rendering_limits_enabled?, to: :namespace_settings - before_save :update_new_emails_created_column, if: -> { emails_disabled_changed? } before_create :sync_share_with_group_lock_with_parent before_update :sync_share_with_group_lock_with_parent, if: :parent_changed? after_update :force_share_with_group_lock_on_descendants, if: -> { saved_change_to_share_with_group_lock? && share_with_group_lock? } @@ -712,17 +713,6 @@ def cross_project_reference?(from) end end - def update_new_emails_created_column - return if namespace_settings.nil? - return if namespace_settings.emails_enabled == !emails_disabled - - if namespace_settings.persisted? - namespace_settings.update!(emails_enabled: !emails_disabled) - elsif namespace_settings - namespace_settings.emails_enabled = !emails_disabled - end - end - def cluster_enabled_granted? (Gitlab.com? || Gitlab.dev_or_test_env?) && root_ancestor.cluster_enabled_grant.present? end diff --git a/app/models/namespace_setting.rb b/app/models/namespace_setting.rb index 7970fbc40ba5654af532a0324168ede95417eb4e..64634c03f677d3174c635d1f8dc5f5a08cd4ee43 100644 --- a/app/models/namespace_setting.rb +++ b/app/models/namespace_setting.rb @@ -36,6 +36,7 @@ class NamespaceSetting < ApplicationRecord chronic_duration_attr :project_runner_token_expiration_interval_human_readable, :project_runner_token_expiration_interval NAMESPACE_SETTINGS_PARAMS = %i[ + emails_enabled default_branch_name resource_access_token_creation_allowed prevent_sharing_groups_outside_hierarchy diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index 262cc31627cf5634ba4e06e61c18729c59dbb9bf..f28cf6dadd5a09760fe9fec83c1d7567f50fc217 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -135,7 +135,7 @@ def reject_parent_id! # overridden in EE def remove_unallowed_params - params.delete(:emails_disabled) unless can?(current_user, :set_emails_disabled, group) + params.delete(:emails_enabled) unless can?(current_user, :set_emails_disabled, group) unless can?(current_user, :update_default_branch_protection, group) params.delete(:default_branch_protection) diff --git a/app/views/groups/settings/_permissions.html.haml b/app/views/groups/settings/_permissions.html.haml index 15e245c6fb43bc09b22f0b5817f99310f24c9244..ff2aa1e32bc6d7f008b73f10c8f3ad2ecd878da1 100644 --- a/app/views/groups/settings/_permissions.html.haml +++ b/app/views/groups/settings/_permissions.html.haml @@ -18,10 +18,10 @@ help_text: share_with_group_lock_help_text(@group) .form-group.gl-mb-3 - = f.gitlab_ui_checkbox_component :emails_disabled, - s_('GroupSettings|Email notifications are disabled'), - checkbox_options: { checked: @group.emails_disabled?, disabled: !can_disable_group_emails?(@group) }, - help_text: s_('GroupSettings|Overrides user notification preferences for all members of the group, subgroups, and projects.') + = f.gitlab_ui_checkbox_component :emails_enabled, + s_('GroupSettings|Enable email notifications'), + checkbox_options: { checked: @group.emails_enabled?, disabled: !can_disable_group_emails?(@group) }, + help_text: s_('GroupSettings|Enable sending email notifications for this group and all its subgroups and projects') .form-group.gl-mb-3 = f.gitlab_ui_checkbox_component :mentions_disabled, diff --git a/ee/app/assets/javascripts/epic_boards/index.js b/ee/app/assets/javascripts/epic_boards/index.js index f5cb1d8c8ee19f1d7a92ebac0feb4507080e6a0c..14dcf2ca803bc1a1795bfe6beaf6d864ae8004d6 100644 --- a/ee/app/assets/javascripts/epic_boards/index.js +++ b/ee/app/assets/javascripts/epic_boards/index.js @@ -57,7 +57,7 @@ function mountBoardApp(el) { timeTrackingLimitToHours: parseBoolean(el.dataset.timeTrackingLimitToHours), boardWeight: el.dataset.boardWeight ? parseInt(el.dataset.boardWeight, 10) : null, issuableType: TYPE_EPIC, - emailsDisabled: parseBoolean(el.dataset.emailsDisabled), + emailsDisabled: !parseBoolean(el.dataset.emailsEnabled), hasMissingBoards: parseBoolean(el.dataset.hasMissingBoards), weights: JSON.parse(el.dataset.weights), isIssueBoard: false, diff --git a/ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb b/ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb index fdbed10e06f772408c71e014dac4f7b73d03d95a..500f8be5f980e3124e892c06d570dde4172da07a 100644 --- a/ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb +++ b/ee/spec/features/epic_boards/epic_boards_sidebar_spec.rb @@ -207,7 +207,7 @@ context 'when notifications have been disabled' do before do - group.update_attribute(:emails_disabled, true) + group.update_attribute(:emails_enabled, false) refresh_and_click_first_card end diff --git a/lib/bulk_imports/groups/transformers/group_attributes_transformer.rb b/lib/bulk_imports/groups/transformers/group_attributes_transformer.rb index 85b52117dbc1293358c7abd70a9d159f14e96f6f..9afaf4f59ac915f4ec1001d2d8ab1726e890ec2c 100644 --- a/lib/bulk_imports/groups/transformers/group_attributes_transformer.rb +++ b/lib/bulk_imports/groups/transformers/group_attributes_transformer.rb @@ -23,7 +23,7 @@ def transform(context, data) 'path' => uniquify(namespace, path, :path), 'description' => data['description'], 'lfs_enabled' => data['lfs_enabled'], - 'emails_disabled' => data['emails_disabled'], + 'emails_enabled' => !data['emails_disabled'], 'mentions_disabled' => data['mentions_disabled'], 'share_with_group_lock' => data['share_with_group_lock'] } diff --git a/locale/gitlab.pot b/locale/gitlab.pot index d4bebce60710c6736465ac7bc51df9c44acfeeeb..6889995bf840f94fbb4c3a4a6c7832810a841a75 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -24701,15 +24701,18 @@ msgstr "" msgid "GroupSettings|Default to Auto DevOps pipeline for all projects within this group" msgstr "" -msgid "GroupSettings|Email notifications are disabled" +msgid "GroupSettings|Enable caching of hierarchical objects (subgroups and projects) to improve the performance of group-level features within a large group." msgstr "" -msgid "GroupSettings|Enable caching of hierarchical objects (subgroups and projects) to improve the performance of group-level features within a large group." +msgid "GroupSettings|Enable email notifications" msgstr "" msgid "GroupSettings|Enable overview background aggregation for Value Streams Dashboard" msgstr "" +msgid "GroupSettings|Enable sending email notifications for this group and all its subgroups and projects" +msgstr "" + msgid "GroupSettings|Enabling these features is your acceptance of the %{link_start}GitLab Testing Agreement%{link_end}." msgstr "" @@ -24758,9 +24761,6 @@ msgstr "" msgid "GroupSettings|Organizations and contacts can be created and associated with issues." msgstr "" -msgid "GroupSettings|Overrides user notification preferences for all members of the group, subgroups, and projects." -msgstr "" - msgid "GroupSettings|Pipeline settings was updated for the group" msgstr "" diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb index fd69ea7a260a93daa782ed15a9becff21219b47d..d32ddbcfa34dc485418d7539198bbb0511d96f48 100644 --- a/spec/features/groups/group_settings_spec.rb +++ b/spec/features/groups/group_settings_spec.rb @@ -211,18 +211,18 @@ end end - context 'disable email notifications' do + context 'enable email notifications' do it 'is visible' do visit edit_group_path(group) - expect(page).to have_selector('#group_emails_disabled', visible: true) + expect(page).to have_selector('#group_emails_enabled', visible: true) end it 'accepts the changed state' do visit edit_group_path(group) - check 'group_emails_disabled' + uncheck 'group_emails_enabled' - expect { save_permissions_group }.to change { updated_emails_disabled? }.to(true) + expect { save_permissions_group }.to change { updated_emails_enabled? }.to(false) end end @@ -328,8 +328,8 @@ def save_permissions_group end end - def updated_emails_disabled? + def updated_emails_enabled? group.reload.clear_memoization(:emails_enabled_memoized) - group.emails_disabled? + group.emails_enabled? end end diff --git a/spec/frontend/sidebar/components/subscriptions/subscriptions_spec.js b/spec/frontend/sidebar/components/subscriptions/subscriptions_spec.js index b644b7a942144c4b125a94891b03330f75a6614b..8ca98f1adfb578a382a8b26c9314596f929d5f37 100644 --- a/spec/frontend/sidebar/components/subscriptions/subscriptions_spec.js +++ b/spec/frontend/sidebar/components/subscriptions/subscriptions_spec.js @@ -89,7 +89,7 @@ describe('Subscriptions', () => { beforeEach(() => { mountComponent({ subscribed: false, - projectEmailsDisabled: true, + projectEmailsEnabled: false, subscribeDisabledDescription, }); }); diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index dd23dbb0370fbd12373394ce1b98e0e3d7f32619..6c7d1c246cff49c434d275ab9bc35733ce4ec622 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -18,7 +18,7 @@ web_url avatar_url share_with_group_lock project_creation_level descendant_groups_count group_members_count projects_count subgroup_creation_level require_two_factor_authentication - two_factor_grace_period auto_devops_enabled emails_disabled + two_factor_grace_period auto_devops_enabled emails_disabled emails_enabled mentions_disabled parent boards milestones group_members merge_requests container_repositories container_repositories_count packages dependency_proxy_setting dependency_proxy_manifests diff --git a/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb b/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb index 69d5997cf96d33fef33b8f7b8e784682b3b7f558..5730071b694d6fb5b7dea78fa60f63352432bf7a 100644 --- a/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb +++ b/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb @@ -51,7 +51,7 @@ 'visibility_level' => Gitlab::VisibilityLevel.string_options[data['visibility']], 'project_creation_level' => Gitlab::Access.project_creation_string_options[data['project_creation_level']], 'subgroup_creation_level' => Gitlab::Access.subgroup_creation_string_options[data['subgroup_creation_level']], - 'emails_disabled' => true, + 'emails_enabled' => false, 'lfs_enabled' => false, 'mentions_disabled' => true, 'share_with_group_lock' => false, @@ -78,7 +78,7 @@ 'description' => 'Source Group Description', 'parent_id' => destination_group.id, 'share_with_group_lock' => nil, - 'emails_disabled' => nil, + 'emails_enabled' => true, 'lfs_enabled' => nil, 'mentions_disabled' => nil }) diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 25bcd26519e1186bac1d36b340b4608b0b4f2852..054dba5d7f6dddb5c1f8c4d4b813229a9abcb738 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -3091,8 +3091,6 @@ def define_cache_expectations(cache_key) end describe '#first_owner' do - let(:group) { build(:group) } - context 'the group has owners' do it 'is the first owner' do user_1 = create(:user) @@ -3217,10 +3215,15 @@ def define_cache_expectations(cache_key) shared_examples 'returns namespaces with disabled email' do subject(:group_ids_where_email_is_disabled) { described_class.ids_with_disabled_email([child_1, child_2, other_group]) } - it do + it "when a group's parent has disabled emails" do parent_1.update_attribute(:emails_enabled, false) is_expected.to eq(Set.new([child_1.id])) end + + it "when a group itself has disabled emails" do + child_2.update_attribute(:emails_enabled, false) + is_expected.to eq(Set.new([child_2.id])) + end end it_behaves_like 'returns namespaces with disabled email' diff --git a/spec/models/namespace_setting_spec.rb b/spec/models/namespace_setting_spec.rb index 5358446c333aa458e31a8d8f4bdd986e5cf05b57..b8c20c4d591ef769384de7c8842e1a9bd7d7310e 100644 --- a/spec/models/namespace_setting_spec.rb +++ b/spec/models/namespace_setting_spec.rb @@ -208,52 +208,42 @@ end describe '#emails_enabled?' do - context 'when a group has no parent' - let(:settings) { create(:namespace_settings, emails_enabled: true) } - let(:grandparent) { create(:group) } - let(:parent) { create(:group, parent: grandparent) } - let(:group) { create(:group, parent: parent, namespace_settings: settings) } + let_it_be_with_refind(:group) { create(:group) } - context 'when the groups setting is changed' do - it 'returns false when the attribute is false' do - group.update_attribute(:emails_enabled, false) + it 'returns true when the attribute is true' do + group.emails_enabled = true - expect(group.emails_enabled?).to be_falsey - end + expect(group.emails_enabled?).to be_truthy end - context 'when a group has a parent' do - it 'returns true when no parent has disabled emails' do - expect(group.emails_enabled?).to be_truthy - end - - context 'when ancestor emails are disabled' do - it 'returns false' do - grandparent.update_attribute(:emails_enabled, false) + it 'returns false when the attribute is false' do + group.emails_enabled = false - expect(group.emails_enabled?).to be_falsey - end - end + expect(group.emails_enabled?).to be_falsey end context 'when a group has parent groups' do - let(:grandparent) { create(:group, namespace_settings: settings) } - let(:parent) { create(:group, parent: grandparent) } - let!(:group) { create(:group, parent: parent) } + let_it_be(:grandparent) { create(:group) } + let_it_be(:parent) { create(:group, parent: grandparent) } + let_it_be_with_refind(:group) { create(:group, parent: parent) } - context "when a parent group has emails disabled" do - let(:settings) { create(:namespace_settings, emails_enabled: false) } + it 'returns true when no parent has disabled emails' do + expect(group.emails_enabled?).to be_truthy + end + context 'when grandparent emails are disabled' do it 'returns false' do + grandparent.update!(emails_enabled: false) + expect(group.emails_enabled?).to be_falsey end end - context 'when all parent groups have emails enabled' do - let(:settings) { create(:namespace_settings, emails_enabled: true) } + context "when parent emails are disabled" do + it 'returns false' do + parent.update!(emails_enabled: false) - it 'returns true' do - expect(group.emails_enabled?).to be_truthy + expect(group.emails_enabled?).to be_falsey end end end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 55f08a310dc952198e45d930c86a19f8b10ea661..8cf924b0eec60b7e39878c6263af585442deeb46 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1957,64 +1957,16 @@ end describe '#emails_disabled?' do - context 'when not a subgroup' do - let(:group) { create(:group) } - - it 'returns false' do - group.update_attribute(:emails_enabled, true) - - expect(group.emails_disabled?).to be_falsey - end - - it 'returns true' do - group.update_attribute(:emails_enabled, false) - - expect(group.emails_disabled?).to be_truthy - end - - it 'does not query the db when there is no parent group' do - group.update_attribute(:emails_enabled, false) - - expect { group.emails_disabled? }.not_to exceed_query_limit(0) - end - end + let_it_be_with_refind(:group) { create(:group) } - context 'when a subgroup' do - let(:grandparent) { create(:group) } - let(:parent) { create(:group, parent: grandparent) } - let(:group) { create(:group, parent: parent) } - - it 'returns false' do - expect(group.emails_disabled?).to be_falsey - end - - context 'when ancestor emails are disabled' do - it 'returns true' do - grandparent.update_attribute(:emails_disabled, true) - - expect(group.emails_disabled?).to be_truthy - end - end - end - end - - describe '#emails_enabled?' do - context 'without a persisted namespace_setting object' do - let(:group_settings) { create(:namespace_settings) } - let(:group) { build(:group, emails_disabled: false, namespace_settings: group_settings) } - - it "is the opposite of emails_disabled" do - expect(group.emails_enabled?).to be_truthy - end + it 'returns false when emails are enabled' do + expect(group.emails_disabled?).to be_falsey end - context 'with a persisted namespace_setting object' do - let(:namespace_settings) { create(:namespace_settings, emails_enabled: true) } - let(:group) { build(:group, emails_disabled: false, namespace_settings: namespace_settings) } + it 'returns true when emails are disabled' do + group.emails_enabled = false - it "is the opposite of emails_disabled" do - expect(group.emails_enabled?).to be_truthy - end + expect(group.emails_disabled?).to be_truthy end end diff --git a/spec/models/project_setting_spec.rb b/spec/models/project_setting_spec.rb index 8ad232b7e0c58c82e8a9b97ad6e74b08e6fb373f..1344032840be3d3f96f6fa86cd161bdb33fbc3a9 100644 --- a/spec/models/project_setting_spec.rb +++ b/spec/models/project_setting_spec.rb @@ -206,7 +206,7 @@ def valid_target_platform_combinations context 'when emails have been disabled in parent group' do it 'returns false' do - group.update_attribute(:emails_disabled, true) + group.update_attribute(:emails_enabled, false) expect(project.emails_enabled?).to be_falsey end diff --git a/spec/presenters/issue_presenter_spec.rb b/spec/presenters/issue_presenter_spec.rb index 6c971a55e7455ada08caa1c3c0e3a2e815bfeb68..3391ec6d8ca60beeb1e4fe533f96437df37fa188 100644 --- a/spec/presenters/issue_presenter_spec.rb +++ b/spec/presenters/issue_presenter_spec.rb @@ -105,6 +105,38 @@ end end + describe '#parent_emails_enabled?' do + subject { presenter.parent_emails_enabled? } + + it 'returns true when email notifications are enabled for the project' do + is_expected.to be(true) + end + + context 'when email notifications are disabled for the project' do + before do + allow(project).to receive(:emails_enabled?).and_return(false) + end + + it { is_expected.to be(false) } + end + + context 'when issue is group-level' do + let(:presented_issue) { create(:issue, :group_level, namespace: group) } + + it 'returns true when email notifications are enabled for the group' do + is_expected.to be(true) + end + + context 'when email notifications are disabled for the group' do + before do + allow(group).to receive(:emails_enabled?).and_return(false) + end + + it { is_expected.to be(false) } + end + end + end + describe '#service_desk_reply_to' do context 'when issue is not a service desk issue' do subject { presenter.service_desk_reply_to } diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index 7ac3382672dde2e96a0860828fc41416c5537585..ed1395a38e91308aed2f93432098ebea5b8c4e70 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -374,19 +374,19 @@ end end - context 'when updating #emails_disabled' do - let(:service) { described_class.new(internal_group, user, emails_disabled: true) } + context 'when updating #emails_enabled' do + let(:service) { described_class.new(internal_group, user, emails_enabled: false) } it 'updates the attribute' do internal_group.add_member(user, Gitlab::Access::OWNER) - expect { service.execute }.to change { internal_group.emails_disabled }.to(true) + expect { service.execute }.to change { internal_group.emails_enabled }.to(false) end it 'does not update when not group owner' do internal_group.add_member(user, Gitlab::Access::MAINTAINER) - expect { service.execute }.not_to change { internal_group.emails_disabled } + expect { service.execute }.not_to change { internal_group.emails_enabled } end end diff --git a/spec/support/shared_examples/services/notification_service_shared_examples.rb b/spec/support/shared_examples/services/notification_service_shared_examples.rb index c53872ca4bc402068e1ed2ac46ac6256f269f3a4..44076d144a9cd1140fbf23dcc526f6075d07254a 100644 --- a/spec/support/shared_examples/services/notification_service_shared_examples.rb +++ b/spec/support/shared_examples/services/notification_service_shared_examples.rb @@ -49,7 +49,7 @@ end it 'sends no emails with group emails disabled' do - target_group.update_attribute(:emails_disabled, true) + target_group.update_attribute(:emails_enabled, false) notification_trigger @@ -57,7 +57,7 @@ end it 'sends emails to someone' do - target_group.update_attribute(:emails_disabled, false) + target_group.update_attribute(:emails_enabled, true) notification_trigger