BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3c15f0ea
Commit
3c15f0ea
authored
Jun 02, 2017
by
Mark Fletcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept a username for User-level Events API
parent
ad3e180e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
events.md
doc/api/events.md
+1
-1
events.rb
lib/api/events.rb
+2
-2
events_spec.rb
spec/requests/api/events_spec.rb
+9
-0
No files found.
doc/api/events.md
View file @
3c15f0ea
...
@@ -129,7 +129,7 @@ Parameters:
...
@@ -129,7 +129,7 @@ Parameters:
| Attribute | Type | Required | Description |
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer | yes | The ID of the user |
|
`id`
| integer | yes | The ID o
r Username o
f the user |
|
`action`
| string | no | Include only events of a particular
[
action type
][
action-types
]
|
|
`action`
| string | no | Include only events of a particular
[
action type
][
action-types
]
|
|
`target_type`
| string | no | Include only events of a particular
[
target type
][
target-types
]
|
|
`target_type`
| string | no | Include only events of a particular
[
target type
][
target-types
]
|
|
`before`
| date | no | Include only events created before a particular date. Please see
[
here for the supported format
][
date-formatting
]
|
|
`before`
| date | no | Include only events created before a particular date. Please see
[
here for the supported format
][
date-formatting
]
|
...
...
lib/api/events.rb
View file @
3c15f0ea
...
@@ -42,7 +42,7 @@ module API
...
@@ -42,7 +42,7 @@ module API
end
end
params
do
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID
of the user'
requires
:id
,
type:
String
,
desc:
'The ID or Username
of the user'
end
end
resource
:users
do
resource
:users
do
desc
'Get the contribution events of a specified user'
do
desc
'Get the contribution events of a specified user'
do
...
@@ -55,7 +55,7 @@ module API
...
@@ -55,7 +55,7 @@ module API
use
:sort_params
use
:sort_params
end
end
get
':id/events'
do
get
':id/events'
do
user
=
User
.
find_by
(
id:
params
[
:id
])
user
=
find_user
(
params
[
:id
])
not_found!
(
'User'
)
unless
user
not_found!
(
'User'
)
unless
user
events
=
EventsFinder
.
new
(
params
.
merge
(
source:
user
,
current_user:
current_user
)).
execute
.
preload
(
:author
,
:target
)
events
=
EventsFinder
.
new
(
params
.
merge
(
source:
user
,
current_user:
current_user
)).
execute
.
preload
(
:author
,
:target
)
...
...
spec/requests/api/events_spec.rb
View file @
3c15f0ea
...
@@ -41,6 +41,15 @@ describe API::Events, api: true do
...
@@ -41,6 +41,15 @@ describe API::Events, api: true do
end
end
context
"as a user that can see the event's project"
do
context
"as a user that can see the event's project"
do
it
'accepts a username'
do
get
api
(
"/users/
#{
user
.
username
}
/events"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
end
it
'returns the events'
do
it
'returns the events'
do
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
...
...
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