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
cf00fbec
Commit
cf00fbec
authored
Sep 16, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix API notes endpoint when posting only emoji
parent
065341bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
doc/api/notes.md
doc/api/notes.md
+5
-1
lib/api/notes.rb
lib/api/notes.rb
+4
-4
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+9
-0
No files found.
doc/api/notes.md
View file @
cf00fbec
...
@@ -78,7 +78,8 @@ Parameters:
...
@@ -78,7 +78,8 @@ Parameters:
### Create new issue note
### Create new issue note
Creates a new note to a single project issue.
Creates a new note to a single project issue. If you create a note where the body
only contains an Award Emoji, you'll receive this object back.
```
```
POST /projects/:id/issues/:issue_id/notes
POST /projects/:id/issues/:issue_id/notes
...
@@ -204,6 +205,7 @@ Parameters:
...
@@ -204,6 +205,7 @@ Parameters:
### Create new snippet note
### Create new snippet note
Creates a new note for a single snippet. Snippet notes are comments users can post to a snippet.
Creates a new note for a single snippet. Snippet notes are comments users can post to a snippet.
If you create a note where the body only contains an Award Emoji, you'll receive this object back.
```
```
POST /projects/:id/snippets/:snippet_id/notes
POST /projects/:id/snippets/:snippet_id/notes
...
@@ -332,6 +334,8 @@ Parameters:
...
@@ -332,6 +334,8 @@ Parameters:
### Create new merge request note
### Create new merge request note
Creates a new note for a single merge request.
Creates a new note for a single merge request.
If you create a note where the body only contains an Award Emoji, you'll receive
this object back.
```
```
POST /projects/:id/merge_requests/:merge_request_id/notes
POST /projects/:id/merge_requests/:merge_request_id/notes
...
...
lib/api/notes.rb
View file @
cf00fbec
...
@@ -83,12 +83,12 @@ module API
...
@@ -83,12 +83,12 @@ module API
opts
[
:created_at
]
=
params
[
:created_at
]
opts
[
:created_at
]
=
params
[
:created_at
]
end
end
@
note
=
::
Notes
::
CreateService
.
new
(
user_project
,
current_user
,
opts
).
execute
note
=
::
Notes
::
CreateService
.
new
(
user_project
,
current_user
,
opts
).
execute
if
@
note
.
valid?
if
note
.
valid?
present
@note
,
with:
Entities
::
Note
present
note
,
with:
Entities
::
const_get
(
note
.
class
.
name
)
else
else
not_found!
(
"Note
#{
@
note
.
errors
.
messages
}
"
)
not_found!
(
"Note
#{
note
.
errors
.
messages
}
"
)
end
end
end
end
...
...
spec/requests/api/notes_spec.rb
View file @
cf00fbec
...
@@ -220,6 +220,15 @@ describe API::API, api: true do
...
@@ -220,6 +220,15 @@ describe API::API, api: true do
expect
(
Time
.
parse
(
json_response
[
'created_at'
])).
to
be_within
(
1
.
second
).
of
(
creation_time
)
expect
(
Time
.
parse
(
json_response
[
'created_at'
])).
to
be_within
(
1
.
second
).
of
(
creation_time
)
end
end
end
end
context
'when the user is posting an award emoji'
do
it
'returns an award emoji'
do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
),
body:
':+1:'
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'awardable_id'
]).
to
eq
issue
.
id
end
end
end
end
context
"when noteable is a Snippet"
do
context
"when noteable is a Snippet"
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