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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4de7f32c
Commit
4de7f32c
authored
Dec 04, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'extend-events-api'
parents
1f5a6eb2
3227a5ea
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
14 deletions
+106
-14
CHANGELOG
CHANGELOG
+1
-0
doc/api/notes.md
doc/api/notes.md
+12
-3
doc/api/projects.md
doc/api/projects.md
+67
-4
lib/api/entities.rb
lib/api/entities.rb
+3
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+23
-7
No files found.
CHANGELOG
View file @
4de7f32c
...
@@ -8,6 +8,7 @@ v 8.3.0 (unreleased)
...
@@ -8,6 +8,7 @@ v 8.3.0 (unreleased)
- Fire update hook from GitLab
- Fire update hook from GitLab
- Don't show project fork event as "imported"
- Don't show project fork event as "imported"
- Add API endpoint to fetch merge request commits list
- Add API endpoint to fetch merge request commits list
- Expose events API with comment information and author info
v 8.2.2
v 8.2.2
- Fix 404 in redirection after removing a project (Stan Hu)
- Fix 404 in redirection after removing a project (Stan Hu)
...
...
doc/api/notes.md
View file @
4de7f32c
...
@@ -35,7 +35,9 @@ Parameters:
...
@@ -35,7 +35,9 @@ Parameters:
"created_at"
:
"2013-10-02T09:22:45Z"
,
"created_at"
:
"2013-10-02T09:22:45Z"
,
"system"
:
true
,
"system"
:
true
,
"upvote"
:
false
,
"upvote"
:
false
,
"downvote"
:
false
"downvote"
:
false
,
"noteable_id"
:
377
,
"noteable_type"
:
"Issue"
},
},
{
{
"id"
:
305
,
"id"
:
305
,
...
@@ -52,7 +54,9 @@ Parameters:
...
@@ -52,7 +54,9 @@ Parameters:
"created_at"
:
"2013-10-02T09:56:03Z"
,
"created_at"
:
"2013-10-02T09:56:03Z"
,
"system"
:
true
,
"system"
:
true
,
"upvote"
:
false
,
"upvote"
:
false
,
"downvote"
:
false
"downvote"
:
false
,
"noteable_id"
:
121
,
"noteable_type"
:
"Issue"
}
}
]
]
```
```
...
@@ -219,7 +223,12 @@ Parameters:
...
@@ -219,7 +223,12 @@ Parameters:
"state"
:
"active"
,
"state"
:
"active"
,
"created_at"
:
"2013-09-30T13:46:01Z"
"created_at"
:
"2013-09-30T13:46:01Z"
},
},
"created_at"
:
"2013-10-02T08:57:14Z"
"created_at"
:
"2013-10-02T08:57:14Z"
,
"system"
:
false
,
"upvote"
:
false
,
"downvote"
:
false
,
"noteable_id"
:
2
,
"noteable_type"
:
"MergeRequest"
}
}
```
```
...
...
doc/api/projects.md
View file @
4de7f32c
...
@@ -245,9 +245,17 @@ Parameters:
...
@@ -245,9 +245,17 @@ Parameters:
"target_id"
:
830
,
"target_id"
:
830
,
"target_type"
:
"Issue"
,
"target_type"
:
"Issue"
,
"author_id"
:
1
,
"author_id"
:
1
,
"author_username"
:
"john"
,
"data"
:
null
,
"data"
:
null
,
"target_title"
:
"Public project search field"
"target_title"
:
"Public project search field"
,
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://localhost:3000/uploads/user/avatar/1/fox_avatar.png"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"author_username"
:
"root"
},
},
{
{
"title"
:
null
,
"title"
:
null
,
...
@@ -256,6 +264,14 @@ Parameters:
...
@@ -256,6 +264,14 @@ Parameters:
"target_id"
:
null
,
"target_id"
:
null
,
"target_type"
:
null
,
"target_type"
:
null
,
"author_id"
:
1
,
"author_id"
:
1
,
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://localhost:3000/uploads/user/avatar/1/fox_avatar.png"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"author_username"
:
"john"
,
"author_username"
:
"john"
,
"data"
:
{
"data"
:
{
"before"
:
"50d4420237a9de7be1304607147aec22e4a14af7"
,
"before"
:
"50d4420237a9de7be1304607147aec22e4a14af7"
,
...
@@ -292,9 +308,56 @@ Parameters:
...
@@ -292,9 +308,56 @@ Parameters:
"target_id"
:
840
,
"target_id"
:
840
,
"target_type"
:
"Issue"
,
"target_type"
:
"Issue"
,
"author_id"
:
1
,
"author_id"
:
1
,
"author_username"
:
"john"
,
"data"
:
null
,
"data"
:
null
,
"target_title"
:
"Finish & merge Code search PR"
"target_title"
:
"Finish & merge Code search PR"
,
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://localhost:3000/uploads/user/avatar/1/fox_avatar.png"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"author_username"
:
"root"
},
{
"title"
:
null
,
"project_id"
:
15
,
"action_name"
:
"commented on"
,
"target_id"
:
1312
,
"target_type"
:
"Note"
,
"author_id"
:
1
,
"data"
:
null
,
"target_title"
:
null
,
"created_at"
:
"2015-12-04T10:33:58.089Z"
,
"note"
:
{
"id"
:
1312
,
"body"
:
"What an awesome day!"
,
"attachment"
:
null
,
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://localhost:3000/uploads/user/avatar/1/fox_avatar.png"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"created_at"
:
"2015-12-04T10:33:56.698Z"
,
"system"
:
false
,
"upvote"
:
false
,
"downvote"
:
false
,
"noteable_id"
:
377
,
"noteable_type"
:
"Issue"
},
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://localhost:3000/uploads/user/avatar/1/fox_avatar.png"
,
"web_url"
:
"http://localhost:3000/u/root"
},
"author_username"
:
"root"
}
}
]
]
```
```
...
...
lib/api/entities.rb
View file @
4de7f32c
...
@@ -194,6 +194,7 @@ module API
...
@@ -194,6 +194,7 @@ module API
expose
:author
,
using:
Entities
::
UserBasic
expose
:author
,
using:
Entities
::
UserBasic
expose
:created_at
expose
:created_at
expose
:system?
,
as: :system
expose
:system?
,
as: :system
expose
:noteable_id
,
:noteable_type
# upvote? and downvote? are deprecated, always return false
# upvote? and downvote? are deprecated, always return false
expose
:upvote?
,
as: :upvote
expose
:upvote?
,
as: :upvote
expose
:downvote?
,
as: :downvote
expose
:downvote?
,
as: :downvote
...
@@ -224,6 +225,8 @@ module API
...
@@ -224,6 +225,8 @@ module API
expose
:target_id
,
:target_type
,
:author_id
expose
:target_id
,
:target_type
,
:author_id
expose
:data
,
:target_title
expose
:data
,
:target_title
expose
:created_at
expose
:created_at
expose
:note
,
using:
Entities
::
Note
,
if:
->
(
event
,
options
)
{
event
.
note?
}
expose
:author
,
using:
Entities
::
UserBasic
,
if:
->
(
event
,
options
)
{
event
.
author
}
expose
:author_username
do
|
event
,
options
|
expose
:author_username
do
|
event
,
options
|
if
event
.
author
if
event
.
author
...
...
spec/requests/api/projects_spec.rb
View file @
4de7f32c
...
@@ -389,14 +389,30 @@ describe API::API, api: true do
...
@@ -389,14 +389,30 @@ describe API::API, api: true do
describe
'GET /projects/:id/events'
do
describe
'GET /projects/:id/events'
do
before
{
project_member2
}
before
{
project_member2
}
it
'should return a project events'
do
context
'valid request'
do
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
user
)
before
do
expect
(
response
.
status
).
to
eq
(
200
)
note
=
create
(
:note_on_issue
,
note:
'What an awesome day!'
,
project:
project
)
json_event
=
json_response
.
first
EventCreateService
.
new
.
leave_note
(
note
,
note
.
author
)
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
user
)
end
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
context
'joined event'
do
let
(
:json_event
)
{
json_response
[
1
]
}
expect
(
json_event
[
'action_name'
]).
to
eq
(
'joined'
)
it
{
expect
(
json_event
[
'action_name'
]).
to
eq
(
'joined'
)
}
expect
(
json_event
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
it
{
expect
(
json_event
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
}
expect
(
json_event
[
'author_username'
]).
to
eq
(
user3
.
username
)
it
{
expect
(
json_event
[
'author_username'
]).
to
eq
(
user3
.
username
)
}
it
{
expect
(
json_event
[
'author'
][
'name'
]).
to
eq
(
user3
.
name
)
}
end
context
'comment event'
do
let
(
:json_event
)
{
json_response
.
first
}
it
{
expect
(
json_event
[
'action_name'
]).
to
eq
(
'commented on'
)
}
it
{
expect
(
json_event
[
'note'
][
'body'
]).
to
eq
(
'What an awesome day!'
)
}
end
end
end
it
'should return a 404 error if not found'
do
it
'should return a 404 error if not found'
do
...
...
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