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
c53fb89e
Commit
c53fb89e
authored
Dec 20, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
6e051e66
24c9e1e2
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
94 additions
and
82 deletions
+94
-82
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-1
app/controllers/concerns/group_tree.rb
app/controllers/concerns/group_tree.rb
+2
-2
app/finders/group_descendants_finder.rb
app/finders/group_descendants_finder.rb
+3
-3
app/finders/groups_finder.rb
app/finders/groups_finder.rb
+2
-2
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+1
-1
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-1
app/models/concerns/descendant.rb
app/models/concerns/descendant.rb
+11
-0
app/models/group.rb
app/models/group.rb
+1
-4
app/models/namespace.rb
app/models/namespace.rb
+8
-8
app/models/project.rb
app/models/project.rb
+1
-1
app/models/user.rb
app/models/user.rb
+3
-3
app/policies/group_policy.rb
app/policies/group_policy.rb
+1
-1
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+1
-1
app/services/groups/nested_create_service.rb
app/services/groups/nested_create_service.rb
+1
-1
app/services/groups/transfer_service.rb
app/services/groups/transfer_service.rb
+1
-1
app/services/users/refresh_authorized_projects_service.rb
app/services/users/refresh_authorized_projects_service.rb
+1
-1
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/groups.rb
lib/api/groups.rb
+1
-1
lib/gitlab/object_hierarchy.rb
lib/gitlab/object_hierarchy.rb
+27
-23
spec/features/groups/show_spec.rb
spec/features/groups/show_spec.rb
+2
-2
spec/lib/gitlab/bare_repository_import/importer_spec.rb
spec/lib/gitlab/bare_repository_import/importer_spec.rb
+1
-1
spec/lib/gitlab/object_hierarchy_spec.rb
spec/lib/gitlab/object_hierarchy_spec.rb
+4
-4
spec/lib/gitlab/project_authorizations_spec.rb
spec/lib/gitlab/project_authorizations_spec.rb
+2
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-2
spec/policies/group_policy_spec.rb
spec/policies/group_policy_spec.rb
+4
-4
spec/requests/openid_connect_spec.rb
spec/requests/openid_connect_spec.rb
+1
-1
spec/services/groups/create_service_spec.rb
spec/services/groups/create_service_spec.rb
+2
-2
spec/services/groups/nested_create_service_spec.rb
spec/services/groups/nested_create_service_spec.rb
+1
-1
spec/services/groups/transfer_service_spec.rb
spec/services/groups/transfer_service_spec.rb
+1
-1
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+4
-4
spec/spec_helper.rb
spec/spec_helper.rb
+1
-1
No files found.
app/controllers/application_controller.rb
View file @
c53fb89e
...
@@ -403,7 +403,7 @@ class ApplicationController < ActionController::Base
...
@@ -403,7 +403,7 @@ class ApplicationController < ActionController::Base
end
end
def
manifest_import_enabled?
def
manifest_import_enabled?
Group
.
supports_nested_
group
s?
&&
Gitlab
::
CurrentSettings
.
import_sources
.
include?
(
'manifest'
)
Group
.
supports_nested_
object
s?
&&
Gitlab
::
CurrentSettings
.
import_sources
.
include?
(
'manifest'
)
end
end
# U2F (universal 2nd factor) devices need a unique identifier for the application
# U2F (universal 2nd factor) devices need a unique identifier for the application
...
...
app/controllers/concerns/group_tree.rb
View file @
c53fb89e
...
@@ -32,14 +32,14 @@ module GroupTree
...
@@ -32,14 +32,14 @@ module GroupTree
def
filtered_groups_with_ancestors
(
groups
)
def
filtered_groups_with_ancestors
(
groups
)
filtered_groups
=
groups
.
search
(
params
[
:filter
]).
page
(
params
[
:page
])
filtered_groups
=
groups
.
search
(
params
[
:filter
]).
page
(
params
[
:page
])
if
Group
.
supports_nested_
group
s?
if
Group
.
supports_nested_
object
s?
# We find the ancestors by ID of the search results here.
# We find the ancestors by ID of the search results here.
# Otherwise the ancestors would also have filters applied,
# Otherwise the ancestors would also have filters applied,
# which would cause them not to be preloaded.
# which would cause them not to be preloaded.
#
#
# Pagination needs to be applied before loading the ancestors to
# Pagination needs to be applied before loading the ancestors to
# make sure ancestors are not cut off by pagination.
# make sure ancestors are not cut off by pagination.
Gitlab
::
Group
Hierarchy
.
new
(
Group
.
where
(
id:
filtered_groups
.
select
(
:id
)))
Gitlab
::
Object
Hierarchy
.
new
(
Group
.
where
(
id:
filtered_groups
.
select
(
:id
)))
.
base_and_ancestors
.
base_and_ancestors
else
else
filtered_groups
filtered_groups
...
...
app/finders/group_descendants_finder.rb
View file @
c53fb89e
...
@@ -112,7 +112,7 @@ class GroupDescendantsFinder
...
@@ -112,7 +112,7 @@ class GroupDescendantsFinder
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
ancestors_of_groups
(
base_for_ancestors
)
def
ancestors_of_groups
(
base_for_ancestors
)
group_ids
=
base_for_ancestors
.
except
(
:select
,
:sort
).
select
(
:id
)
group_ids
=
base_for_ancestors
.
except
(
:select
,
:sort
).
select
(
:id
)
Gitlab
::
Group
Hierarchy
.
new
(
Group
.
where
(
id:
group_ids
))
Gitlab
::
Object
Hierarchy
.
new
(
Group
.
where
(
id:
group_ids
))
.
base_and_ancestors
(
upto:
parent_group
.
id
)
.
base_and_ancestors
(
upto:
parent_group
.
id
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
@@ -132,7 +132,7 @@ class GroupDescendantsFinder
...
@@ -132,7 +132,7 @@ class GroupDescendantsFinder
end
end
def
subgroups
def
subgroups
return
Group
.
none
unless
Group
.
supports_nested_
group
s?
return
Group
.
none
unless
Group
.
supports_nested_
object
s?
# When filtering subgroups, we want to find all matches withing the tree of
# When filtering subgroups, we want to find all matches withing the tree of
# descendants to show to the user
# descendants to show to the user
...
@@ -183,7 +183,7 @@ class GroupDescendantsFinder
...
@@ -183,7 +183,7 @@ class GroupDescendantsFinder
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
hierarchy_for_parent
def
hierarchy_for_parent
@hierarchy
||=
Gitlab
::
Group
Hierarchy
.
new
(
Group
.
where
(
id:
parent_group
.
id
))
@hierarchy
||=
Gitlab
::
Object
Hierarchy
.
new
(
Group
.
where
(
id:
parent_group
.
id
))
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
end
end
app/finders/groups_finder.rb
View file @
c53fb89e
...
@@ -46,7 +46,7 @@ class GroupsFinder < UnionFinder
...
@@ -46,7 +46,7 @@ class GroupsFinder < UnionFinder
return
[
Group
.
all
]
if
current_user
&
.
full_private_access?
&&
all_available?
return
[
Group
.
all
]
if
current_user
&
.
full_private_access?
&&
all_available?
groups
=
[]
groups
=
[]
groups
<<
Gitlab
::
GroupHierarchy
.
new
(
groups_for_ancestors
,
groups_for_descendants
).
all_group
s
if
current_user
groups
<<
Gitlab
::
ObjectHierarchy
.
new
(
groups_for_ancestors
,
groups_for_descendants
).
all_object
s
if
current_user
groups
<<
Group
.
unscoped
.
public_to_user
(
current_user
)
if
include_public_groups?
groups
<<
Group
.
unscoped
.
public_to_user
(
current_user
)
if
include_public_groups?
groups
<<
Group
.
none
if
groups
.
empty?
groups
<<
Group
.
none
if
groups
.
empty?
groups
groups
...
@@ -66,7 +66,7 @@ class GroupsFinder < UnionFinder
...
@@ -66,7 +66,7 @@ class GroupsFinder < UnionFinder
.
groups
.
groups
.
where
(
'members.access_level >= ?'
,
params
[
:min_access_level
])
.
where
(
'members.access_level >= ?'
,
params
[
:min_access_level
])
Gitlab
::
Group
Hierarchy
Gitlab
::
Object
Hierarchy
.
new
(
groups
)
.
new
(
groups
)
.
base_and_descendants
.
base_and_descendants
end
end
...
...
app/helpers/groups_helper.rb
View file @
c53fb89e
...
@@ -126,7 +126,7 @@ module GroupsHelper
...
@@ -126,7 +126,7 @@ module GroupsHelper
end
end
def
supports_nested_groups?
def
supports_nested_groups?
Group
.
supports_nested_
group
s?
Group
.
supports_nested_
object
s?
end
end
private
private
...
...
app/models/ci/runner.rb
View file @
c53fb89e
...
@@ -66,7 +66,7 @@ module Ci
...
@@ -66,7 +66,7 @@ module Ci
scope
:belonging_to_parent_group_of_project
,
->
(
project_id
)
{
scope
:belonging_to_parent_group_of_project
,
->
(
project_id
)
{
project_groups
=
::
Group
.
joins
(
:projects
).
where
(
projects:
{
id:
project_id
})
project_groups
=
::
Group
.
joins
(
:projects
).
where
(
projects:
{
id:
project_id
})
hierarchy_groups
=
Gitlab
::
Group
Hierarchy
.
new
(
project_groups
).
base_and_ancestors
hierarchy_groups
=
Gitlab
::
Object
Hierarchy
.
new
(
project_groups
).
base_and_ancestors
joins
(
:groups
).
where
(
namespaces:
{
id:
hierarchy_groups
})
joins
(
:groups
).
where
(
namespaces:
{
id:
hierarchy_groups
})
}
}
...
...
app/models/concerns/descendant.rb
0 → 100644
View file @
c53fb89e
# frozen_string_literal: true
module
Descendant
extend
ActiveSupport
::
Concern
class_methods
do
def
supports_nested_objects?
Gitlab
::
Database
.
postgresql?
end
end
end
app/models/group.rb
View file @
c53fb89e
...
@@ -10,6 +10,7 @@ class Group < Namespace
...
@@ -10,6 +10,7 @@ class Group < Namespace
include
Referable
include
Referable
include
SelectForProjectAuthorization
include
SelectForProjectAuthorization
include
LoadedInGroupList
include
LoadedInGroupList
include
Descendant
include
GroupDescendant
include
GroupDescendant
include
TokenAuthenticatable
include
TokenAuthenticatable
include
WithUploads
include
WithUploads
...
@@ -63,10 +64,6 @@ class Group < Namespace
...
@@ -63,10 +64,6 @@ class Group < Namespace
after_update
:path_changed_hook
,
if: :path_changed?
after_update
:path_changed_hook
,
if: :path_changed?
class
<<
self
class
<<
self
def
supports_nested_groups?
Gitlab
::
Database
.
postgresql?
end
def
sort_by_attribute
(
method
)
def
sort_by_attribute
(
method
)
if
method
==
'storage_size_desc'
if
method
==
'storage_size_desc'
# storage_size is a virtual column so we need to
# storage_size is a virtual column so we need to
...
...
app/models/namespace.rb
View file @
c53fb89e
...
@@ -175,16 +175,16 @@ class Namespace < ActiveRecord::Base
...
@@ -175,16 +175,16 @@ class Namespace < ActiveRecord::Base
# Returns all ancestors, self, and descendants of the current namespace.
# Returns all ancestors, self, and descendants of the current namespace.
def
self_and_hierarchy
def
self_and_hierarchy
Gitlab
::
Group
Hierarchy
Gitlab
::
Object
Hierarchy
.
new
(
self
.
class
.
where
(
id:
id
))
.
new
(
self
.
class
.
where
(
id:
id
))
.
all_
group
s
.
all_
object
s
end
end
# Returns all the ancestors of the current namespaces.
# Returns all the ancestors of the current namespaces.
def
ancestors
def
ancestors
return
self
.
class
.
none
unless
parent_id
return
self
.
class
.
none
unless
parent_id
Gitlab
::
Group
Hierarchy
Gitlab
::
Object
Hierarchy
.
new
(
self
.
class
.
where
(
id:
parent_id
))
.
new
(
self
.
class
.
where
(
id:
parent_id
))
.
base_and_ancestors
.
base_and_ancestors
end
end
...
@@ -192,27 +192,27 @@ class Namespace < ActiveRecord::Base
...
@@ -192,27 +192,27 @@ class Namespace < ActiveRecord::Base
# returns all ancestors upto but excluding the given namespace
# returns all ancestors upto but excluding the given namespace
# when no namespace is given, all ancestors upto the top are returned
# when no namespace is given, all ancestors upto the top are returned
def
ancestors_upto
(
top
=
nil
,
hierarchy_order:
nil
)
def
ancestors_upto
(
top
=
nil
,
hierarchy_order:
nil
)
Gitlab
::
Group
Hierarchy
.
new
(
self
.
class
.
where
(
id:
id
))
Gitlab
::
Object
Hierarchy
.
new
(
self
.
class
.
where
(
id:
id
))
.
ancestors
(
upto:
top
,
hierarchy_order:
hierarchy_order
)
.
ancestors
(
upto:
top
,
hierarchy_order:
hierarchy_order
)
end
end
def
self_and_ancestors
def
self_and_ancestors
return
self
.
class
.
where
(
id:
id
)
unless
parent_id
return
self
.
class
.
where
(
id:
id
)
unless
parent_id
Gitlab
::
Group
Hierarchy
Gitlab
::
Object
Hierarchy
.
new
(
self
.
class
.
where
(
id:
id
))
.
new
(
self
.
class
.
where
(
id:
id
))
.
base_and_ancestors
.
base_and_ancestors
end
end
# Returns all the descendants of the current namespace.
# Returns all the descendants of the current namespace.
def
descendants
def
descendants
Gitlab
::
Group
Hierarchy
Gitlab
::
Object
Hierarchy
.
new
(
self
.
class
.
where
(
parent_id:
id
))
.
new
(
self
.
class
.
where
(
parent_id:
id
))
.
base_and_descendants
.
base_and_descendants
end
end
def
self_and_descendants
def
self_and_descendants
Gitlab
::
Group
Hierarchy
Gitlab
::
Object
Hierarchy
.
new
(
self
.
class
.
where
(
id:
id
))
.
new
(
self
.
class
.
where
(
id:
id
))
.
base_and_descendants
.
base_and_descendants
end
end
...
@@ -293,7 +293,7 @@ class Namespace < ActiveRecord::Base
...
@@ -293,7 +293,7 @@ class Namespace < ActiveRecord::Base
end
end
def
force_share_with_group_lock_on_descendants
def
force_share_with_group_lock_on_descendants
return
unless
Group
.
supports_nested_
group
s?
return
unless
Group
.
supports_nested_
object
s?
# We can't use `descendants.update_all` since Rails will throw away the WITH
# We can't use `descendants.update_all` since Rails will throw away the WITH
# RECURSIVE statement. We also can't use WHERE EXISTS since we can't use
# RECURSIVE statement. We also can't use WHERE EXISTS since we can't use
...
...
app/models/project.rb
View file @
c53fb89e
...
@@ -570,7 +570,7 @@ class Project < ActiveRecord::Base
...
@@ -570,7 +570,7 @@ class Project < ActiveRecord::Base
# returns all ancestor-groups upto but excluding the given namespace
# returns all ancestor-groups upto but excluding the given namespace
# when no namespace is given, all ancestors upto the top are returned
# when no namespace is given, all ancestors upto the top are returned
def
ancestors_upto
(
top
=
nil
,
hierarchy_order:
nil
)
def
ancestors_upto
(
top
=
nil
,
hierarchy_order:
nil
)
Gitlab
::
Group
Hierarchy
.
new
(
Group
.
where
(
id:
namespace_id
))
Gitlab
::
Object
Hierarchy
.
new
(
Group
.
where
(
id:
namespace_id
))
.
base_and_ancestors
(
upto:
top
,
hierarchy_order:
hierarchy_order
)
.
base_and_ancestors
(
upto:
top
,
hierarchy_order:
hierarchy_order
)
end
end
...
...
app/models/user.rb
View file @
c53fb89e
...
@@ -709,13 +709,13 @@ class User < ActiveRecord::Base
...
@@ -709,13 +709,13 @@ class User < ActiveRecord::Base
# Returns the groups a user is a member of, either directly or through a parent group
# Returns the groups a user is a member of, either directly or through a parent group
def
membership_groups
def
membership_groups
Gitlab
::
Group
Hierarchy
.
new
(
groups
).
base_and_descendants
Gitlab
::
Object
Hierarchy
.
new
(
groups
).
base_and_descendants
end
end
# Returns a relation of groups the user has access to, including their parent
# Returns a relation of groups the user has access to, including their parent
# and child groups (recursively).
# and child groups (recursively).
def
all_expanded_groups
def
all_expanded_groups
Gitlab
::
GroupHierarchy
.
new
(
groups
).
all_group
s
Gitlab
::
ObjectHierarchy
.
new
(
groups
).
all_object
s
end
end
def
expanded_groups_requiring_two_factor_authentication
def
expanded_groups_requiring_two_factor_authentication
...
@@ -1153,7 +1153,7 @@ class User < ActiveRecord::Base
...
@@ -1153,7 +1153,7 @@ class User < ActiveRecord::Base
end
end
def
manageable_groups
def
manageable_groups
Gitlab
::
Group
Hierarchy
.
new
(
owned_or_maintainers_groups
).
base_and_descendants
Gitlab
::
Object
Hierarchy
.
new
(
owned_or_maintainers_groups
).
base_and_descendants
end
end
def
namespaces
def
namespaces
...
...
app/policies/group_policy.rb
View file @
c53fb89e
...
@@ -16,7 +16,7 @@ class GroupPolicy < BasePolicy
...
@@ -16,7 +16,7 @@ class GroupPolicy < BasePolicy
condition
(
:maintainer
)
{
access_level
>=
GroupMember
::
MAINTAINER
}
condition
(
:maintainer
)
{
access_level
>=
GroupMember
::
MAINTAINER
}
condition
(
:reporter
)
{
access_level
>=
GroupMember
::
REPORTER
}
condition
(
:reporter
)
{
access_level
>=
GroupMember
::
REPORTER
}
condition
(
:nested_groups_supported
,
scope: :global
)
{
Group
.
supports_nested_
group
s?
}
condition
(
:nested_groups_supported
,
scope: :global
)
{
Group
.
supports_nested_
object
s?
}
condition
(
:has_parent
,
scope: :subject
)
{
@subject
.
has_parent?
}
condition
(
:has_parent
,
scope: :subject
)
{
@subject
.
has_parent?
}
condition
(
:share_with_group_locked
,
scope: :subject
)
{
@subject
.
share_with_group_lock?
}
condition
(
:share_with_group_locked
,
scope: :subject
)
{
@subject
.
share_with_group_lock?
}
...
...
app/services/ci/register_job_service.rb
View file @
c53fb89e
...
@@ -118,7 +118,7 @@ module Ci
...
@@ -118,7 +118,7 @@ module Ci
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
groups
=
::
Group
.
joins
(
:runner_namespaces
).
merge
(
runner
.
runner_namespaces
)
groups
=
::
Group
.
joins
(
:runner_namespaces
).
merge
(
runner
.
runner_namespaces
)
hierarchy_groups
=
Gitlab
::
Group
Hierarchy
.
new
(
groups
).
base_and_descendants
hierarchy_groups
=
Gitlab
::
Object
Hierarchy
.
new
(
groups
).
base_and_descendants
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
.
with_group_runners_enabled
.
with_group_runners_enabled
.
with_builds_enabled
.
with_builds_enabled
...
...
app/services/groups/nested_create_service.rb
View file @
c53fb89e
...
@@ -18,7 +18,7 @@ module Groups
...
@@ -18,7 +18,7 @@ module Groups
return
namespace
return
namespace
end
end
if
group_path
.
include?
(
'/'
)
&&
!
Group
.
supports_nested_
group
s?
if
group_path
.
include?
(
'/'
)
&&
!
Group
.
supports_nested_
object
s?
raise
'Nested groups are not supported on MySQL'
raise
'Nested groups are not supported on MySQL'
end
end
...
...
app/services/groups/transfer_service.rb
View file @
c53fb89e
...
@@ -40,7 +40,7 @@ module Groups
...
@@ -40,7 +40,7 @@ module Groups
def
ensure_allowed_transfer
def
ensure_allowed_transfer
raise_transfer_error
(
:group_is_already_root
)
if
group_is_already_root?
raise_transfer_error
(
:group_is_already_root
)
if
group_is_already_root?
raise_transfer_error
(
:database_not_supported
)
unless
Group
.
supports_nested_
group
s?
raise_transfer_error
(
:database_not_supported
)
unless
Group
.
supports_nested_
object
s?
raise_transfer_error
(
:same_parent_as_current
)
if
same_parent?
raise_transfer_error
(
:same_parent_as_current
)
if
same_parent?
raise_transfer_error
(
:invalid_policies
)
unless
valid_policies?
raise_transfer_error
(
:invalid_policies
)
unless
valid_policies?
raise_transfer_error
(
:namespace_with_same_path
)
if
namespace_with_same_path?
raise_transfer_error
(
:namespace_with_same_path
)
if
namespace_with_same_path?
...
...
app/services/users/refresh_authorized_projects_service.rb
View file @
c53fb89e
...
@@ -102,7 +102,7 @@ module Users
...
@@ -102,7 +102,7 @@ module Users
end
end
def
fresh_authorizations
def
fresh_authorizations
klass
=
if
Group
.
supports_nested_
group
s?
klass
=
if
Group
.
supports_nested_
object
s?
Gitlab
::
ProjectAuthorizations
::
WithNestedGroups
Gitlab
::
ProjectAuthorizations
::
WithNestedGroups
else
else
Gitlab
::
ProjectAuthorizations
::
WithoutNestedGroups
Gitlab
::
ProjectAuthorizations
::
WithoutNestedGroups
...
...
lib/api/entities.rb
View file @
c53fb89e
...
@@ -323,7 +323,7 @@ module API
...
@@ -323,7 +323,7 @@ module API
expose
:request_access_enabled
expose
:request_access_enabled
expose
:full_name
,
:full_path
expose
:full_name
,
:full_path
if
::
Group
.
supports_nested_
group
s?
if
::
Group
.
supports_nested_
object
s?
expose
:parent_id
expose
:parent_id
end
end
...
...
lib/api/groups.rb
View file @
c53fb89e
...
@@ -124,7 +124,7 @@ module API
...
@@ -124,7 +124,7 @@ module API
requires
:name
,
type:
String
,
desc:
'The name of the group'
requires
:name
,
type:
String
,
desc:
'The name of the group'
requires
:path
,
type:
String
,
desc:
'The path of the group'
requires
:path
,
type:
String
,
desc:
'The path of the group'
if
::
Group
.
supports_nested_
group
s?
if
::
Group
.
supports_nested_
object
s?
optional
:parent_id
,
type:
Integer
,
desc:
'The parent group id for creating nested group'
optional
:parent_id
,
type:
Integer
,
desc:
'The parent group id for creating nested group'
end
end
...
...
lib/gitlab/
group
_hierarchy.rb
→
lib/gitlab/
object
_hierarchy.rb
View file @
c53fb89e
# frozen_string_literal: true
# frozen_string_literal: true
module
Gitlab
module
Gitlab
# Retrieving of parent or child
group
s based on a base ActiveRecord relation.
# Retrieving of parent or child
object
s based on a base ActiveRecord relation.
#
#
# This class uses recursive CTEs and as a result will only work on PostgreSQL.
# This class uses recursive CTEs and as a result will only work on PostgreSQL.
class
Group
Hierarchy
class
Object
Hierarchy
attr_reader
:ancestors_base
,
:descendants_base
,
:model
attr_reader
:ancestors_base
,
:descendants_base
,
:model
# ancestors_base - An instance of ActiveRecord::Relation for which to
# ancestors_base - An instance of ActiveRecord::Relation for which to
# get parent
group
s.
# get parent
object
s.
# descendants_base - An instance of ActiveRecord::Relation for which to
# descendants_base - An instance of ActiveRecord::Relation for which to
# get child
group
s. If omitted, ancestors_base is used.
# get child
object
s. If omitted, ancestors_base is used.
def
initialize
(
ancestors_base
,
descendants_base
=
ancestors_base
)
def
initialize
(
ancestors_base
,
descendants_base
=
ancestors_base
)
raise
ArgumentError
.
new
(
"Model of ancestors_base does not match model of descendants_base"
)
if
ancestors_base
.
model
!=
descendants_base
.
model
raise
ArgumentError
.
new
(
"Model of ancestors_base does not match model of descendants_base"
)
if
ancestors_base
.
model
!=
descendants_base
.
model
...
@@ -53,13 +53,13 @@ module Gitlab
...
@@ -53,13 +53,13 @@ module Gitlab
# included.
# included.
#
#
# Passing a `hierarchy_order` with either `:asc` or `:desc` will cause the
# Passing a `hierarchy_order` with either `:asc` or `:desc` will cause the
# recursive query order from most nested
group
to root or from the root
# recursive query order from most nested
object
to root or from the root
# ancestor to most nested
group
respectively. This uses a `depth` column
# ancestor to most nested
object
respectively. This uses a `depth` column
# where `1` is defined as the depth for the base and increment as we go up
# where `1` is defined as the depth for the base and increment as we go up
# each parent.
# each parent.
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
base_and_ancestors
(
upto:
nil
,
hierarchy_order:
nil
)
def
base_and_ancestors
(
upto:
nil
,
hierarchy_order:
nil
)
return
ancestors_base
unless
Group
.
supports_nested_groups
?
return
ancestors_base
unless
hierarchy_supported
?
recursive_query
=
base_and_ancestors_cte
(
upto
,
hierarchy_order
).
apply_to
(
model
.
all
)
recursive_query
=
base_and_ancestors_cte
(
upto
,
hierarchy_order
).
apply_to
(
model
.
all
)
recursive_query
=
recursive_query
.
order
(
depth:
hierarchy_order
)
if
hierarchy_order
recursive_query
=
recursive_query
.
order
(
depth:
hierarchy_order
)
if
hierarchy_order
...
@@ -68,16 +68,16 @@ module Gitlab
...
@@ -68,16 +68,16 @@ module Gitlab
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
# Returns a relation that includes the descendants_base set of
group
s
# Returns a relation that includes the descendants_base set of
object
s
# and all their descendants (recursively).
# and all their descendants (recursively).
def
base_and_descendants
def
base_and_descendants
return
descendants_base
unless
Group
.
supports_nested_groups
?
return
descendants_base
unless
hierarchy_supported
?
read_only
(
base_and_descendants_cte
.
apply_to
(
model
.
all
))
read_only
(
base_and_descendants_cte
.
apply_to
(
model
.
all
))
end
end
# Returns a relation that includes the base
group
s, their ancestors,
# Returns a relation that includes the base
object
s, their ancestors,
# and the descendants of the base
group
s.
# and the descendants of the base
object
s.
#
#
# The resulting query will roughly look like the following:
# The resulting query will roughly look like the following:
#
#
...
@@ -97,16 +97,16 @@ module Gitlab
...
@@ -97,16 +97,16 @@ module Gitlab
# Using this approach allows us to further add criteria to the relation with
# Using this approach allows us to further add criteria to the relation with
# Rails thinking it's selecting data the usual way.
# Rails thinking it's selecting data the usual way.
#
#
# If nested
group
s are not supported, ancestors_base is returned.
# If nested
object
s are not supported, ancestors_base is returned.
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
all_
group
s
def
all_
object
s
return
ancestors_base
unless
Group
.
supports_nested_groups
?
return
ancestors_base
unless
hierarchy_supported
?
ancestors
=
base_and_ancestors_cte
ancestors
=
base_and_ancestors_cte
descendants
=
base_and_descendants_cte
descendants
=
base_and_descendants_cte
ancestors_table
=
ancestors
.
alias_to
(
group
s_table
)
ancestors_table
=
ancestors
.
alias_to
(
object
s_table
)
descendants_table
=
descendants
.
alias_to
(
group
s_table
)
descendants_table
=
descendants
.
alias_to
(
object
s_table
)
relation
=
model
relation
=
model
.
unscoped
.
unscoped
...
@@ -123,23 +123,27 @@ module Gitlab
...
@@ -123,23 +123,27 @@ module Gitlab
private
private
def
hierarchy_supported?
Gitlab
::
Database
.
postgresql?
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
base_and_ancestors_cte
(
stop_id
=
nil
,
hierarchy_order
=
nil
)
def
base_and_ancestors_cte
(
stop_id
=
nil
,
hierarchy_order
=
nil
)
cte
=
SQL
::
RecursiveCTE
.
new
(
:base_and_ancestors
)
cte
=
SQL
::
RecursiveCTE
.
new
(
:base_and_ancestors
)
depth_column
=
:depth
depth_column
=
:depth
base_query
=
ancestors_base
.
except
(
:order
)
base_query
=
ancestors_base
.
except
(
:order
)
base_query
=
base_query
.
select
(
"1 as
#{
depth_column
}
"
,
group
s_table
[
Arel
.
star
])
if
hierarchy_order
base_query
=
base_query
.
select
(
"1 as
#{
depth_column
}
"
,
object
s_table
[
Arel
.
star
])
if
hierarchy_order
cte
<<
base_query
cte
<<
base_query
# Recursively get all the ancestors of the base set.
# Recursively get all the ancestors of the base set.
parent_query
=
model
parent_query
=
model
.
from
([
group
s_table
,
cte
.
table
])
.
from
([
object
s_table
,
cte
.
table
])
.
where
(
group
s_table
[
:id
].
eq
(
cte
.
table
[
:parent_id
]))
.
where
(
object
s_table
[
:id
].
eq
(
cte
.
table
[
:parent_id
]))
.
except
(
:order
)
.
except
(
:order
)
parent_query
=
parent_query
.
select
(
cte
.
table
[
depth_column
]
+
1
,
group
s_table
[
Arel
.
star
])
if
hierarchy_order
parent_query
=
parent_query
.
select
(
cte
.
table
[
depth_column
]
+
1
,
object
s_table
[
Arel
.
star
])
if
hierarchy_order
parent_query
=
parent_query
.
where
(
cte
.
table
[
:parent_id
].
not_eq
(
stop_id
))
if
stop_id
parent_query
=
parent_query
.
where
(
cte
.
table
[
:parent_id
].
not_eq
(
stop_id
))
if
stop_id
cte
<<
parent_query
cte
<<
parent_query
...
@@ -155,15 +159,15 @@ module Gitlab
...
@@ -155,15 +159,15 @@ module Gitlab
# Recursively get all the descendants of the base set.
# Recursively get all the descendants of the base set.
cte
<<
model
cte
<<
model
.
from
([
group
s_table
,
cte
.
table
])
.
from
([
object
s_table
,
cte
.
table
])
.
where
(
group
s_table
[
:parent_id
].
eq
(
cte
.
table
[
:id
]))
.
where
(
object
s_table
[
:parent_id
].
eq
(
cte
.
table
[
:id
]))
.
except
(
:order
)
.
except
(
:order
)
cte
cte
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
group
s_table
def
object
s_table
model
.
arel_table
model
.
arel_table
end
end
...
...
spec/features/groups/show_spec.rb
View file @
c53fb89e
...
@@ -65,7 +65,7 @@ describe 'Group show page' do
...
@@ -65,7 +65,7 @@ describe 'Group show page' do
context
'when subgroups are supported'
,
:js
,
:nested_groups
do
context
'when subgroups are supported'
,
:js
,
:nested_groups
do
before
do
before
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
)
{
true
}
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
)
{
true
}
visit
path
visit
path
end
end
...
@@ -76,7 +76,7 @@ describe 'Group show page' do
...
@@ -76,7 +76,7 @@ describe 'Group show page' do
context
'when subgroups are not supported'
do
context
'when subgroups are not supported'
do
before
do
before
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
)
{
false
}
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
)
{
false
}
visit
path
visit
path
end
end
...
...
spec/lib/gitlab/bare_repository_import/importer_spec.rb
View file @
c53fb89e
...
@@ -192,7 +192,7 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
...
@@ -192,7 +192,7 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
let
(
:project_path
)
{
'a-group/a-sub-group/a-project'
}
let
(
:project_path
)
{
'a-group/a-sub-group/a-project'
}
before
do
before
do
expect
(
Group
).
to
receive
(
:supports_nested_
group
s?
)
{
false
}
expect
(
Group
).
to
receive
(
:supports_nested_
object
s?
)
{
false
}
end
end
describe
'#create_project_if_needed'
do
describe
'#create_project_if_needed'
do
...
...
spec/lib/gitlab/
group
_hierarchy_spec.rb
→
spec/lib/gitlab/
object
_hierarchy_spec.rb
View file @
c53fb89e
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Group
Hierarchy
,
:postgresql
do
describe
Gitlab
::
Object
Hierarchy
,
:postgresql
do
let!
(
:parent
)
{
create
(
:group
)
}
let!
(
:parent
)
{
create
(
:group
)
}
let!
(
:child1
)
{
create
(
:group
,
parent:
parent
)
}
let!
(
:child1
)
{
create
(
:group
,
parent:
parent
)
}
let!
(
:child2
)
{
create
(
:group
,
parent:
child1
)
}
let!
(
:child2
)
{
create
(
:group
,
parent:
child1
)
}
...
@@ -121,7 +121,7 @@ describe Gitlab::GroupHierarchy, :postgresql do
...
@@ -121,7 +121,7 @@ describe Gitlab::GroupHierarchy, :postgresql do
describe
'#all_groups'
do
describe
'#all_groups'
do
let
(
:relation
)
do
let
(
:relation
)
do
described_class
.
new
(
Group
.
where
(
id:
child1
.
id
)).
all_
group
s
described_class
.
new
(
Group
.
where
(
id:
child1
.
id
)).
all_
object
s
end
end
it
'includes the base rows'
do
it
'includes the base rows'
do
...
@@ -137,13 +137,13 @@ describe Gitlab::GroupHierarchy, :postgresql do
...
@@ -137,13 +137,13 @@ describe Gitlab::GroupHierarchy, :postgresql do
end
end
it
'uses ancestors_base #initialize argument for ancestors'
do
it
'uses ancestors_base #initialize argument for ancestors'
do
relation
=
described_class
.
new
(
Group
.
where
(
id:
child1
.
id
),
Group
.
where
(
id:
Group
.
maximum
(
:id
).
succ
)).
all_
group
s
relation
=
described_class
.
new
(
Group
.
where
(
id:
child1
.
id
),
Group
.
where
(
id:
Group
.
maximum
(
:id
).
succ
)).
all_
object
s
expect
(
relation
).
to
include
(
parent
)
expect
(
relation
).
to
include
(
parent
)
end
end
it
'uses descendants_base #initialize argument for descendants'
do
it
'uses descendants_base #initialize argument for descendants'
do
relation
=
described_class
.
new
(
Group
.
where
(
id:
Group
.
maximum
(
:id
).
succ
),
Group
.
where
(
id:
child1
.
id
)).
all_
group
s
relation
=
described_class
.
new
(
Group
.
where
(
id:
Group
.
maximum
(
:id
).
succ
),
Group
.
where
(
id:
child1
.
id
)).
all_
object
s
expect
(
relation
).
to
include
(
child2
)
expect
(
relation
).
to
include
(
child2
)
end
end
...
...
spec/lib/gitlab/project_authorizations_spec.rb
View file @
c53fb89e
...
@@ -20,7 +20,7 @@ describe Gitlab::ProjectAuthorizations do
...
@@ -20,7 +20,7 @@ describe Gitlab::ProjectAuthorizations do
end
end
let
(
:authorizations
)
do
let
(
:authorizations
)
do
klass
=
if
Group
.
supports_nested_
group
s?
klass
=
if
Group
.
supports_nested_
object
s?
Gitlab
::
ProjectAuthorizations
::
WithNestedGroups
Gitlab
::
ProjectAuthorizations
::
WithNestedGroups
else
else
Gitlab
::
ProjectAuthorizations
::
WithoutNestedGroups
Gitlab
::
ProjectAuthorizations
::
WithoutNestedGroups
...
@@ -46,7 +46,7 @@ describe Gitlab::ProjectAuthorizations do
...
@@ -46,7 +46,7 @@ describe Gitlab::ProjectAuthorizations do
expect
(
mapping
[
group_project
.
id
]).
to
eq
(
Gitlab
::
Access
::
DEVELOPER
)
expect
(
mapping
[
group_project
.
id
]).
to
eq
(
Gitlab
::
Access
::
DEVELOPER
)
end
end
if
Group
.
supports_nested_
group
s?
if
Group
.
supports_nested_
object
s?
context
'with nested groups'
do
context
'with nested groups'
do
let!
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let!
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let!
(
:nested_project
)
{
create
(
:project
,
namespace:
nested_group
)
}
let!
(
:nested_project
)
{
create
(
:project
,
namespace:
nested_group
)
}
...
...
spec/models/project_spec.rb
View file @
c53fb89e
...
@@ -3979,7 +3979,7 @@ describe Project do
...
@@ -3979,7 +3979,7 @@ describe Project do
expect
(
project
.
badges
.
count
).
to
eq
3
expect
(
project
.
badges
.
count
).
to
eq
3
end
end
if
Group
.
supports_nested_
group
s?
if
Group
.
supports_nested_
object
s?
context
'with nested_groups'
do
context
'with nested_groups'
do
let
(
:parent_group
)
{
create
(
:group
)
}
let
(
:parent_group
)
{
create
(
:group
)
}
...
...
spec/models/user_spec.rb
View file @
c53fb89e
...
@@ -1994,7 +1994,7 @@ describe User do
...
@@ -1994,7 +1994,7 @@ describe User do
subject
{
user
.
membership_groups
}
subject
{
user
.
membership_groups
}
if
Group
.
supports_nested_
group
s?
if
Group
.
supports_nested_
object
s?
it
{
is_expected
.
to
contain_exactly
parent_group
,
child_group
}
it
{
is_expected
.
to
contain_exactly
parent_group
,
child_group
}
else
else
it
{
is_expected
.
to
contain_exactly
parent_group
}
it
{
is_expected
.
to
contain_exactly
parent_group
}
...
@@ -2375,7 +2375,7 @@ describe User do
...
@@ -2375,7 +2375,7 @@ describe User do
group
.
add_owner
(
user
)
group
.
add_owner
(
user
)
end
end
if
Group
.
supports_nested_
group
s?
if
Group
.
supports_nested_
object
s?
it
'returns all groups'
do
it
'returns all groups'
do
is_expected
.
to
match_array
[
is_expected
.
to
match_array
[
group
,
group
,
...
...
spec/policies/group_policy_spec.rb
View file @
c53fb89e
...
@@ -148,7 +148,7 @@ describe GroupPolicy do
...
@@ -148,7 +148,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
owner
}
let
(
:current_user
)
{
owner
}
it
do
it
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
true
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
true
)
expect_allowed
(
*
guest_permissions
)
expect_allowed
(
*
guest_permissions
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
reporter_permissions
)
...
@@ -162,7 +162,7 @@ describe GroupPolicy do
...
@@ -162,7 +162,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
admin
}
let
(
:current_user
)
{
admin
}
it
do
it
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
true
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
true
)
expect_allowed
(
*
guest_permissions
)
expect_allowed
(
*
guest_permissions
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
reporter_permissions
)
...
@@ -174,7 +174,7 @@ describe GroupPolicy do
...
@@ -174,7 +174,7 @@ describe GroupPolicy do
describe
'when nested group support feature is disabled'
do
describe
'when nested group support feature is disabled'
do
before
do
before
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
false
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
false
)
end
end
context
'admin'
do
context
'admin'
do
...
@@ -283,7 +283,7 @@ describe GroupPolicy do
...
@@ -283,7 +283,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
owner
}
let
(
:current_user
)
{
owner
}
it
do
it
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
true
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
true
)
expect_allowed
(
*
guest_permissions
)
expect_allowed
(
*
guest_permissions
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
reporter_permissions
)
...
...
spec/requests/openid_connect_spec.rb
View file @
c53fb89e
...
@@ -104,7 +104,7 @@ describe 'OpenID Connect requests' do
...
@@ -104,7 +104,7 @@ describe 'OpenID Connect requests' do
expect
(
json_response
).
to
match
(
id_token_claims
.
merge
(
user_info_claims
))
expect
(
json_response
).
to
match
(
id_token_claims
.
merge
(
user_info_claims
))
expected_groups
=
[
group1
.
full_path
,
group3
.
full_path
]
expected_groups
=
[
group1
.
full_path
,
group3
.
full_path
]
expected_groups
<<
group4
.
full_path
if
Group
.
supports_nested_
group
s?
expected_groups
<<
group4
.
full_path
if
Group
.
supports_nested_
object
s?
expect
(
json_response
[
'groups'
]).
to
match_array
(
expected_groups
)
expect
(
json_response
[
'groups'
]).
to
match_array
(
expected_groups
)
end
end
...
...
spec/services/groups/create_service_spec.rb
View file @
c53fb89e
...
@@ -55,7 +55,7 @@ describe Groups::CreateService, '#execute' do
...
@@ -55,7 +55,7 @@ describe Groups::CreateService, '#execute' do
context
'when nested groups feature is disabled'
do
context
'when nested groups feature is disabled'
do
it
'does not save group and returns an error'
do
it
'does not save group and returns an error'
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
false
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
false
)
is_expected
.
not_to
be_persisted
is_expected
.
not_to
be_persisted
expect
(
subject
.
errors
[
:parent_id
]).
to
include
(
'You don’t have permission to create a subgroup in this group.'
)
expect
(
subject
.
errors
[
:parent_id
]).
to
include
(
'You don’t have permission to create a subgroup in this group.'
)
...
@@ -66,7 +66,7 @@ describe Groups::CreateService, '#execute' do
...
@@ -66,7 +66,7 @@ describe Groups::CreateService, '#execute' do
context
'when nested groups feature is enabled'
do
context
'when nested groups feature is enabled'
do
before
do
before
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
true
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
true
)
end
end
context
'as guest'
do
context
'as guest'
do
...
...
spec/services/groups/nested_create_service_spec.rb
View file @
c53fb89e
...
@@ -30,7 +30,7 @@ describe Groups::NestedCreateService do
...
@@ -30,7 +30,7 @@ describe Groups::NestedCreateService do
let
(
:params
)
{
{
group_path:
'a-group'
}
}
let
(
:params
)
{
{
group_path:
'a-group'
}
}
before
do
before
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
)
{
false
}
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
)
{
false
}
end
end
it
'creates the group'
do
it
'creates the group'
do
...
...
spec/services/groups/transfer_service_spec.rb
View file @
c53fb89e
...
@@ -9,7 +9,7 @@ describe Groups::TransferService, :postgresql do
...
@@ -9,7 +9,7 @@ describe Groups::TransferService, :postgresql do
shared_examples
'ensuring allowed transfer for a group'
do
shared_examples
'ensuring allowed transfer for a group'
do
context
'with other database than PostgreSQL'
do
context
'with other database than PostgreSQL'
do
before
do
before
do
allow
(
Group
).
to
receive
(
:supports_nested_
group
s?
).
and_return
(
false
)
allow
(
Group
).
to
receive
(
:supports_nested_
object
s?
).
and_return
(
false
)
end
end
it
'should return false'
do
it
'should return false'
do
...
...
spec/services/notification_service_spec.rb
View file @
c53fb89e
...
@@ -2292,7 +2292,7 @@ describe NotificationService, :mailer do
...
@@ -2292,7 +2292,7 @@ describe NotificationService, :mailer do
# Creates a nested group only if supported
# Creates a nested group only if supported
# to avoid errors on MySQL
# to avoid errors on MySQL
def
create_nested_group
def
create_nested_group
if
Group
.
supports_nested_
group
s?
if
Group
.
supports_nested_
object
s?
parent_group
=
create
(
:group
,
:public
)
parent_group
=
create
(
:group
,
:public
)
child_group
=
create
(
:group
,
:public
,
parent:
parent_group
)
child_group
=
create
(
:group
,
:public
,
parent:
parent_group
)
...
@@ -2319,7 +2319,7 @@ describe NotificationService, :mailer do
...
@@ -2319,7 +2319,7 @@ describe NotificationService, :mailer do
end
end
def
add_member_for_parent_group
(
user
,
project
)
def
add_member_for_parent_group
(
user
,
project
)
return
unless
Group
.
supports_nested_
group
s?
return
unless
Group
.
supports_nested_
object
s?
project
.
reload
project
.
reload
...
@@ -2327,13 +2327,13 @@ describe NotificationService, :mailer do
...
@@ -2327,13 +2327,13 @@ describe NotificationService, :mailer do
end
end
def
should_email_nested_group_user
(
user
,
times:
1
,
recipients:
email_recipients
)
def
should_email_nested_group_user
(
user
,
times:
1
,
recipients:
email_recipients
)
return
unless
Group
.
supports_nested_
group
s?
return
unless
Group
.
supports_nested_
object
s?
should_email
(
user
,
times:
1
,
recipients:
email_recipients
)
should_email
(
user
,
times:
1
,
recipients:
email_recipients
)
end
end
def
should_not_email_nested_group_user
(
user
,
recipients:
email_recipients
)
def
should_not_email_nested_group_user
(
user
,
recipients:
email_recipients
)
return
unless
Group
.
supports_nested_
group
s?
return
unless
Group
.
supports_nested_
object
s?
should_not_email
(
user
,
recipients:
email_recipients
)
should_not_email
(
user
,
recipients:
email_recipients
)
end
end
...
...
spec/spec_helper.rb
View file @
c53fb89e
...
@@ -226,7 +226,7 @@ RSpec.configure do |config|
...
@@ -226,7 +226,7 @@ RSpec.configure do |config|
end
end
config
.
around
(
:each
,
:nested_groups
)
do
|
example
|
config
.
around
(
:each
,
:nested_groups
)
do
|
example
|
example
.
run
if
Group
.
supports_nested_
group
s?
example
.
run
if
Group
.
supports_nested_
object
s?
end
end
config
.
around
(
:each
,
:postgresql
)
do
|
example
|
config
.
around
(
:each
,
:postgresql
)
do
|
example
|
...
...
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