Commit 2dc97e53 authored by Nikola Milojevic's avatar Nikola Milojevic

Merge branch '345792-fj-use-linear-user-group-notifications-settings-ancestors' into 'master'

User linear version UserGroupNotificationSettingsFinder#execute

See merge request gitlab-org/gitlab!75645
parents cce3194c 9d4a6597
...@@ -7,15 +7,7 @@ class UserGroupNotificationSettingsFinder ...@@ -7,15 +7,7 @@ class UserGroupNotificationSettingsFinder
end end
def execute def execute
# rubocop: disable CodeReuse/ActiveRecord groups_with_ancestors = groups.self_and_ancestors
selected_groups = Group.where(id: groups.select(:id))
groups_with_ancestors = if Feature.enabled?(:linear_user_group_notification_settings_finder_ancestors_scopes, user, default_enabled: :yaml)
selected_groups.self_and_ancestors
else
Gitlab::ObjectHierarchy.new(selected_groups).base_and_ancestors
end
# rubocop: enable CodeReuse/ActiveRecord
@loaded_groups_with_ancestors = groups_with_ancestors.index_by(&:id) @loaded_groups_with_ancestors = groups_with_ancestors.index_by(&:id)
@loaded_notification_settings = user.notification_settings_for_groups(groups_with_ancestors).preload_source_route.index_by(&:source_id) @loaded_notification_settings = user.notification_settings_for_groups(groups_with_ancestors).preload_source_route.index_by(&:source_id)
......
---
name: linear_user_group_notification_settings_finder_ancestors_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74606
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/345792
milestone: '14.6'
type: development
group: group::access
default_enabled: false
...@@ -11,7 +11,6 @@ RSpec.describe UserGroupNotificationSettingsFinder do ...@@ -11,7 +11,6 @@ RSpec.describe UserGroupNotificationSettingsFinder do
subject.map(&proc).uniq subject.map(&proc).uniq
end end
shared_examples 'user group notifications settings tests' do
context 'when the groups have no existing notification settings' do context 'when the groups have no existing notification settings' do
context 'when the groups have no ancestors' do context 'when the groups have no ancestors' do
let_it_be(:groups) { create_list(:group, 3) } let_it_be(:groups) { create_list(:group, 3) }
...@@ -163,15 +162,4 @@ RSpec.describe UserGroupNotificationSettingsFinder do ...@@ -163,15 +162,4 @@ RSpec.describe UserGroupNotificationSettingsFinder do
end end
end end
end end
end
it_behaves_like 'user group notifications settings tests'
context 'when feature flag :linear_user_group_notification_settings_finder_ancestors_scopes is disabled' do
before do
stub_feature_flags(linear_user_group_notification_settings_finder_ancestors_scopes: false)
end
it_behaves_like 'user group notifications settings tests'
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment