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
33db529c
Commit
33db529c
authored
Oct 22, 2021
by
Jan Provaznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude project namespaces from routes
Excludes project namespaces in autocomplete routes finder.
parent
47c7b5cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
app/finders/autocomplete/routes_finder.rb
app/finders/autocomplete/routes_finder.rb
+1
-1
spec/finders/autocomplete/routes_finder_spec.rb
spec/finders/autocomplete/routes_finder_spec.rb
+57
-0
No files found.
app/finders/autocomplete/routes_finder.rb
View file @
33db529c
...
...
@@ -30,7 +30,7 @@ module Autocomplete
class
NamespacesOnly
<
self
def
routables
return
Namespace
.
all
if
current_user
.
admin?
return
Namespace
.
without_project_namespaces
if
current_user
.
admin?
current_user
.
namespaces
end
...
...
spec/finders/autocomplete/routes_finder_spec.rb
0 → 100644
View file @
33db529c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Autocomplete
::
RoutesFinder
do
describe
'#execute'
do
let_it_be
(
:user
)
{
create
(
:user
,
username:
'user_path'
)
}
let_it_be
(
:admin
)
{
create
(
:admin
)
}
let_it_be
(
:group
)
{
create
(
:group
,
path:
'path1'
)
}
let_it_be
(
:group2
)
{
create
(
:group
,
path:
'path2'
)
}
let_it_be
(
:group3
)
{
create
(
:group
,
path:
'not-matching'
)
}
let_it_be
(
:project
)
{
create
(
:project
,
path:
'path3'
,
namespace:
user
.
namespace
)
}
let_it_be
(
:project2
)
{
create
(
:project
,
path:
'path4'
)
}
let_it_be
(
:project_namespace
)
{
create
(
:project_namespace
,
parent:
group
,
path:
'path5'
)
}
let
(
:current_user
)
{
user
}
let
(
:search
)
{
'path'
}
before
do
group
.
add_owner
(
user
)
end
context
'for NamespacesOnly'
do
subject
{
Autocomplete
::
RoutesFinder
::
NamespacesOnly
.
new
(
current_user
,
search:
search
).
execute
}
let
(
:user_route
)
{
Route
.
find_by_path
(
user
.
username
)
}
it
'finds only user namespace and groups matching the search excluding project namespaces'
do
is_expected
.
to
match_array
([
group
.
route
,
user_route
])
end
context
'when user is admin'
do
let
(
:current_user
)
{
admin
}
it
'finds all namespaces matching the search excluding project namespaces'
do
is_expected
.
to
match_array
([
group
.
route
,
group2
.
route
,
user_route
])
end
end
end
context
'for ProjectsOnly'
do
subject
{
Autocomplete
::
RoutesFinder
::
ProjectsOnly
.
new
(
current_user
,
search:
'path'
).
execute
}
it
'finds only matching projects the user has access to'
do
is_expected
.
to
match_array
([
project
.
route
])
end
context
'when user is admin'
do
let
(
:current_user
)
{
admin
}
it
'finds all projects matching the search'
do
is_expected
.
to
match_array
([
project
.
route
,
project2
.
route
])
end
end
end
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