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
5d131e75
Commit
5d131e75
authored
Sep 21, 2021
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation to issues_statistics endpoint
- Add specs
parent
5c2f3a77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
lib/api/issues.rb
lib/api/issues.rb
+5
-0
spec/requests/api/issues/issues_spec.rb
spec/requests/api/issues/issues_spec.rb
+32
-0
No files found.
lib/api/issues.rb
View file @
5d131e75
...
...
@@ -114,6 +114,7 @@ module API
end
get
'/issues_statistics'
do
authenticate!
unless
params
[
:scope
]
==
'all'
validate_anonymous_search_access!
if
params
[
:search
].
present?
present
issues_statistics
,
with:
Grape
::
Presenters
::
Presenter
end
...
...
@@ -189,6 +190,8 @@ module API
use
:issues_stats_params
end
get
":id/issues_statistics"
do
validate_anonymous_search_access!
if
declared_params
[
:search
].
present?
present
issues_statistics
(
group_id:
user_group
.
id
,
include_subgroups:
true
),
with:
Grape
::
Presenters
::
Presenter
end
end
...
...
@@ -225,6 +228,8 @@ module API
use
:issues_stats_params
end
get
":id/issues_statistics"
do
validate_anonymous_search_access!
if
declared_params
[
:search
].
present?
present
issues_statistics
(
project_id:
user_project
.
id
),
with:
Grape
::
Presenters
::
Presenter
end
...
...
spec/requests/api/issues/issues_spec.rb
View file @
5d131e75
...
...
@@ -262,6 +262,38 @@ RSpec.describe API::Issues do
it_behaves_like
'issues statistics'
end
context
'with search param'
do
let
(
:params
)
{
{
scope:
'all'
,
search:
'foo'
}
}
let
(
:counts
)
{
{
all:
1
,
closed:
0
,
opened:
1
}
}
it_behaves_like
'issues statistics'
context
'with anonymous user'
do
let
(
:user
)
{
nil
}
context
'with disable_anonymous_search disabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
false
)
end
it_behaves_like
'issues statistics'
end
context
'with disable_anonymous_search enabled'
do
before
do
stub_feature_flags
(
disable_anonymous_search:
true
)
end
it
'returns a unprocessable entity 422'
do
get
api
(
"/issues_statistics"
),
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:unprocessable_entity
)
expect
(
json_response
[
'message'
]).
to
include
(
'User must be authenticated to use search'
)
end
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