Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4e006d3c
Commit
4e006d3c
authored
Nov 30, 2021
by
Francisco Javier López
Committed by
Vitali Tatarintev
Nov 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use linear version UserGroupNotificationSettingsFinder#execute
parent
0f685998
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
114 deletions
+139
-114
app/finders/user_group_notification_settings_finder.rb
app/finders/user_group_notification_settings_finder.rb
+6
-1
config/feature_flags/development/linear_user_group_notification_settings_finder_ancestors_scopes.yml
...r_group_notification_settings_finder_ancestors_scopes.yml
+8
-0
spec/finders/user_group_notification_settings_finder_spec.rb
spec/finders/user_group_notification_settings_finder_spec.rb
+125
-113
No files found.
app/finders/user_group_notification_settings_finder.rb
View file @
4e006d3c
...
...
@@ -8,7 +8,12 @@ class UserGroupNotificationSettingsFinder
def
execute
# rubocop: disable CodeReuse/ActiveRecord
groups_with_ancestors
=
Gitlab
::
ObjectHierarchy
.
new
(
Group
.
where
(
id:
groups
.
select
(
:id
))).
base_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
)
...
...
config/feature_flags/development/linear_user_group_notification_settings_finder_ancestors_scopes.yml
0 → 100644
View file @
4e006d3c
---
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
spec/finders/user_group_notification_settings_finder_spec.rb
View file @
4e006d3c
...
...
@@ -11,14 +11,15 @@ RSpec.describe UserGroupNotificationSettingsFinder do
subject
.
map
(
&
proc
).
uniq
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 ancestors'
do
let_it_be
(
:groups
)
{
create_list
(
:group
,
3
)
}
it
'will be a default Global notification setting'
,
:aggregate_failures
do
expect
(
subject
.
count
).
to
eq
(
3
)
expect
(
attributes
(
&
:notification_email
)).
to
eq
([
nil
])
expect
(
attributes
(
&
:level
)).
to
eq
([
'global'
])
expect
(
attributes
(
&
:notification_email
)).
to
match_array
([
nil
])
expect
(
attributes
(
&
:level
)).
to
match_array
([
'global'
])
end
end
...
...
@@ -38,11 +39,11 @@ RSpec.describe UserGroupNotificationSettingsFinder do
end
it
'has the same level set'
do
expect
(
attributes
(
&
:level
)).
to
eq
([
'participating'
])
expect
(
attributes
(
&
:level
)).
to
match_array
([
'participating'
])
end
it
'has the same email set'
do
expect
(
attributes
(
&
:notification_email
)).
to
eq
([
'ancestor@example.com'
])
expect
(
attributes
(
&
:notification_email
)).
to
match_array
([
'ancestor@example.com'
])
end
it
'only returns the two queried groups'
do
...
...
@@ -66,8 +67,8 @@ RSpec.describe UserGroupNotificationSettingsFinder do
it
'has the same email and level set'
,
:aggregate_failures
do
expect
(
subject
.
count
).
to
eq
(
1
)
expect
(
attributes
(
&
:level
)).
to
eq
([
'global'
])
expect
(
attributes
(
&
:notification_email
)).
to
eq
([
'ancestor@example.com'
])
expect
(
attributes
(
&
:level
)).
to
match_array
([
'global'
])
expect
(
attributes
(
&
:notification_email
)).
to
match_array
([
'ancestor@example.com'
])
end
end
...
...
@@ -82,8 +83,8 @@ RSpec.describe UserGroupNotificationSettingsFinder do
it
'returns a default Global notification setting'
do
expect
(
subject
.
count
).
to
eq
(
1
)
expect
(
attributes
(
&
:level
)).
to
eq
([
'global'
])
expect
(
attributes
(
&
:notification_email
)).
to
eq
([
nil
])
expect
(
attributes
(
&
:level
)).
to
match_array
([
'global'
])
expect
(
attributes
(
&
:notification_email
)).
to
match_array
([
nil
])
end
end
...
...
@@ -103,8 +104,8 @@ RSpec.describe UserGroupNotificationSettingsFinder do
it
'still inherits the notification settings'
do
expect
(
subject
.
count
).
to
eq
(
1
)
expect
(
attributes
(
&
:level
)).
to
eq
([
'participating'
])
expect
(
attributes
(
&
:notification_email
)).
to
eq
([
ancestor_email
.
email
])
expect
(
attributes
(
&
:level
)).
to
match_array
([
'participating'
])
expect
(
attributes
(
&
:notification_email
)).
to
match_array
([
ancestor_email
.
email
])
end
end
...
...
@@ -162,4 +163,15 @@ RSpec.describe UserGroupNotificationSettingsFinder do
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment