BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
524f6515
Commit
524f6515
authored
Oct 09, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only expand ancestors when searching
Not all_groups, since that would expose groups the user does not have access to
parent
da5073cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
group_tree.rb
app/controllers/concerns/group_tree.rb
+7
-7
group_tree_spec.rb
spec/controllers/concerns/group_tree_spec.rb
+12
-1
No files found.
app/controllers/concerns/group_tree.rb
View file @
524f6515
module
GroupTree
def
render_group_tree
(
groups
)
if
params
[
:filter
].
present?
@groups
=
Gitlab
::
GroupHierarchy
.
new
(
groups
).
all_groups
@groups
=
Gitlab
::
GroupHierarchy
.
new
(
@groups
.
search
(
params
[
:filter
]))
.
base_and_ancestors
else
# Only show root groups if no parent-id is given
@groups
=
groups
.
where
(
parent_id:
params
[
:parent_id
])
end
@groups
=
if
params
[
:filter
].
present?
Gitlab
::
GroupHierarchy
.
new
(
groups
.
search
(
params
[
:filter
]))
.
base_and_ancestors
else
# Only show root groups if no parent-id is given
groups
.
where
(
parent_id:
params
[
:parent_id
])
end
@groups
=
@groups
.
with_selects_for_list
.
sort
(
@sort
=
params
[
:sort
])
.
page
(
params
[
:page
])
...
...
spec/controllers/concerns/group_tree_spec.rb
View file @
524f6515
...
...
@@ -9,7 +9,7 @@ describe GroupTree do
include
GroupTree
# rubocop:disable RSpec/DescribedClass
def
index
render_group_tree
Group
.
all
render_group_tree
Group
sFinder
.
new
(
current_user
).
execute
end
end
...
...
@@ -52,6 +52,17 @@ describe GroupTree do
expect
(
assigns
(
:groups
)).
to
contain_exactly
(
group
,
subgroup
)
end
it
'does not include groups the user does not have access to'
do
parent
=
create
(
:group
,
:private
)
subgroup
=
create
(
:group
,
:private
,
parent:
parent
,
name:
'filter'
)
subgroup
.
add_developer
(
user
)
_other_subgroup
=
create
(
:group
,
:private
,
parent:
parent
,
name:
'filte'
)
get
:index
,
filter:
'filt'
,
format: :json
expect
(
assigns
(
:groups
)).
to
contain_exactly
(
parent
,
subgroup
)
end
end
context
'json content'
do
...
...
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