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
f0f69a97
Commit
f0f69a97
authored
Aug 30, 2019
by
manojmj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds API tests
parent
a608560a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
0 deletions
+91
-0
spec/fixtures/api/schemas/statistics.json
spec/fixtures/api/schemas/statistics.json
+29
-0
spec/requests/api/statistics_spec.rb
spec/requests/api/statistics_spec.rb
+62
-0
No files found.
spec/fixtures/api/schemas/statistics.json
0 → 100644
View file @
f0f69a97
{
"type"
:
"object"
,
"required"
:
[
"forks"
,
"issues"
,
"merge_requests"
,
"notes"
,
"snippets"
,
"ssh_keys"
,
"milestones"
,
"users"
,
"projects"
,
"groups"
,
"active_users"
],
"properties"
:
{
"forks"
:
{
"type"
:
"string"
},
"issues'"
:
{
"type"
:
"string"
},
"merge_requests'"
:
{
"type"
:
"string"
},
"notes'"
:
{
"type"
:
"string"
},
"snippets'"
:
{
"type"
:
"string"
},
"ssh_keys'"
:
{
"type"
:
"string"
},
"milestones'"
:
{
"type"
:
"string"
},
"users'"
:
{
"type"
:
"string"
},
"projects'"
:
{
"type"
:
"string"
},
"groups'"
:
{
"type"
:
"string"
},
"active_users'"
:
{
"type"
:
"string"
}
}
}
spec/requests/api/statistics_spec.rb
0 → 100644
View file @
f0f69a97
require
'spec_helper'
describe
API
::
Statistics
,
'Statistics'
do
let
(
:path
)
{
"/application/statistics"
}
describe
"GET /application/statistics"
do
context
'when no user'
do
it
"returns authentication error"
do
get
api
(
path
,
nil
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
end
context
"when not an admin"
do
let
(
:user
)
{
create
(
:user
)
}
it
"returns forbidden error"
do
get
api
(
path
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
context
'when authenticated as admin'
do
let
(
:admin
)
{
create
(
:admin
)
}
it
'matches the response schema'
do
get
api
(
path
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'statistics'
)
end
it
'gives the right statistics'
do
projects
=
create_list
(
:project
,
4
,
namespace:
create
(
:namespace
,
owner:
admin
))
issues
=
create_list
(
:issue
,
2
,
project:
projects
.
first
,
updated_by:
admin
)
create_list
(
:group
,
2
)
create_list
(
:snippet
,
2
,
:public
,
author:
admin
)
create_list
(
:note
,
2
,
author:
admin
,
project:
projects
.
first
,
noteable:
issues
.
first
)
create_list
(
:milestone
,
3
,
project:
projects
.
first
)
create
(
:key
,
user:
admin
)
create
(
:merge_request
,
source_project:
projects
.
first
)
get
api
(
path
,
admin
)
expect
(
json_response
[
'issues'
]).
to
eq
(
'2'
)
expect
(
json_response
[
'merge_requests'
]).
to
eq
(
'1'
)
expect
(
json_response
[
'notes'
]).
to
eq
(
'2'
)
expect
(
json_response
[
'snippets'
]).
to
eq
(
'2'
)
expect
(
json_response
[
'forks'
]).
to
eq
(
'0'
)
expect
(
json_response
[
'ssh_keys'
]).
to
eq
(
'1'
)
expect
(
json_response
[
'milestones'
]).
to
eq
(
'3'
)
expect
(
json_response
[
'users'
]).
to
eq
(
'1'
)
expect
(
json_response
[
'projects'
]).
to
eq
(
'4'
)
expect
(
json_response
[
'groups'
]).
to
eq
(
'2'
)
expect
(
json_response
[
'active_users'
]).
to
eq
(
'1'
)
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