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
47ef25a1
Commit
47ef25a1
authored
Sep 14, 2021
by
Jake Lear
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add flash message to projects index when search is disabled
parent
d086bd98
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
0 deletions
+73
-0
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+7
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/controllers/explore/projects_controller_spec.rb
spec/controllers/explore/projects_controller_spec.rb
+63
-0
No files found.
app/controllers/explore/projects_controller.rb
View file @
47ef25a1
...
...
@@ -26,6 +26,7 @@ class Explore::ProjectsController < Explore::ApplicationController
feature_category
:projects
def
index
show_alert_if_search_is_disabled
@projects
=
load_projects
respond_to
do
|
format
|
...
...
@@ -120,6 +121,12 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
end
def
show_alert_if_search_is_disabled
return
if
current_user
||
params
[
:name
].
blank?
&&
params
[
:search
].
blank?
||
!
html_request?
||
Feature
.
disabled?
(
:disable_anonymous_search
,
type: :ops
)
flash
[
:notice
]
=
_
(
'You must sign in to search for specific projects.'
)
end
end
Explore
::
ProjectsController
.
prepend_mod_with
(
'Explore::ProjectsController'
)
locale/gitlab.pot
View file @
47ef25a1
...
...
@@ -38758,6 +38758,9 @@ msgstr ""
msgid "You must provide your current password in order to change it."
msgstr ""
msgid "You must sign in to search for specific projects."
msgstr ""
msgid "You must sign in to search for specific terms."
msgstr ""
...
...
spec/controllers/explore/projects_controller_spec.rb
View file @
47ef25a1
...
...
@@ -200,6 +200,24 @@ RSpec.describe Explore::ProjectsController do
let
(
:sorting_param
)
{
'created_asc'
}
end
end
describe
'GET #index'
do
let
(
:controller_action
)
{
:index
}
let
(
:params_with_name
)
{
{
name:
'some project'
}
}
context
'when disable_anonymous_search is enabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
true
)
end
it
'does not show a flash message'
do
sign_in
(
create
(
:user
))
get
controller_action
,
params:
params_with_name
expect
(
flash
[
:notice
]).
to
be_nil
end
end
end
end
context
'when user is not signed in'
do
...
...
@@ -229,5 +247,50 @@ RSpec.describe Explore::ProjectsController do
expect
(
response
).
to
redirect_to
new_user_session_path
end
end
describe
'GET #index'
do
let
(
:controller_action
)
{
:index
}
let
(
:params_with_name
)
{
{
name:
'some project'
}
}
context
'when disable_anonymous_search is enabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
true
)
end
it
'shows a flash message'
do
get
controller_action
,
params:
params_with_name
expect
(
flash
[
:notice
]).
to
eq
(
'You must sign in to search for specific projects.'
)
end
context
'when search param is not given'
do
it
'does not show a flash message'
do
get
controller_action
expect
(
flash
[
:notice
]).
to
be_nil
end
end
context
'when format is not HTML'
do
it
'does not show a flash message'
do
get
controller_action
,
params:
params_with_name
.
merge
(
format: :atom
)
expect
(
flash
[
:notice
]).
to
be_nil
end
end
end
context
'when disable_anonymous_search is disabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
false
)
end
it
'does not show a flash message'
do
get
controller_action
,
params:
params_with_name
expect
(
flash
[
:notice
]).
to
be_nil
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