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
d086bd98
Commit
d086bd98
authored
Sep 14, 2021
by
Jake Lear
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable anonymous searching for ProjectsFinder by feature flag
parent
8a4b65c7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
app/finders/projects_finder.rb
app/finders/projects_finder.rb
+1
-0
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+26
-0
No files found.
app/finders/projects_finder.rb
View file @
d086bd98
...
...
@@ -193,6 +193,7 @@ class ProjectsFinder < UnionFinder
def
by_search
(
items
)
params
[
:search
]
||=
params
[
:name
]
return
items
if
Feature
.
enabled?
(
:disable_anonymous_search
,
type: :ops
)
&&
current_user
.
nil?
return
items
.
none
if
params
[
:search
].
present?
&&
params
[
:minimum_search_length
].
present?
&&
params
[
:search
].
length
<
params
[
:minimum_search_length
].
to_i
items
.
optionally_search
(
params
[
:search
],
include_namespace:
params
[
:search_namespaces
].
present?
)
...
...
spec/finders/projects_finder_spec.rb
View file @
d086bd98
...
...
@@ -190,6 +190,32 @@ RSpec.describe ProjectsFinder do
it
{
is_expected
.
to
eq
([
public_project
])
}
end
context
'with anonymous user'
do
let
(
:public_project_2
)
{
create
(
:project
,
:public
,
group:
group
,
name:
'E'
,
path:
'E'
)
}
let
(
:current_user
)
{
nil
}
let
(
:params
)
{
{
search:
'C'
}
}
context
'with disable_anonymous_search feature flag enabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
true
)
end
it
'does not perform search'
do
is_expected
.
to
eq
([
public_project_2
,
public_project
])
end
end
context
'with disable_anonymous_search feature flag disabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
false
)
end
it
'finds one public project'
do
is_expected
.
to
eq
([
public_project
])
end
end
end
describe
'filter by name for backward compatibility'
do
let
(
:params
)
{
{
name:
'C'
}
}
...
...
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