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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
c946bf88
Commit
c946bf88
authored
Nov 29, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: create new notes
parent
1c5aa848
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
lib/api/notes.rb
lib/api/notes.rb
+22
-0
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+20
-0
No files found.
lib/api/notes.rb
View file @
c946bf88
...
@@ -48,6 +48,28 @@ module Gitlab
...
@@ -48,6 +48,28 @@ module Gitlab
@note
=
@noteable
.
notes
.
find
(
params
[
:note_id
])
@note
=
@noteable
.
notes
.
find
(
params
[
:note_id
])
present
@note
,
with:
Entities
::
Note
present
@note
,
with:
Entities
::
Note
end
end
# Create a new +noteable+ note
#
# Parameters:
# id (required) - The ID or code name of a project
# noteable_id (required) - The ID of an issue or snippet
# body (required) - The content of a note
# Example Request:
# POST /projects/:id/issues/:noteable_id/notes
# POST /projects/:id/snippets/:noteable_id/notes
post
":id/
#{
noteables_str
}
/:
#{
noteable_id_str
}
/notes"
do
@noteable
=
user_project
.
send
(
:"
#{
noteables_str
}
"
).
find
(
params
[
:"
#{
noteable_id_str
}
"
])
@note
=
@noteable
.
notes
.
new
(
note:
params
[
:body
])
@note
.
author
=
current_user
@note
.
project
=
user_project
if
@note
.
save
present
@note
,
with:
Entities
::
Note
else
not_found!
end
end
end
end
end
end
end
end
...
...
spec/requests/api/notes_spec.rb
View file @
c946bf88
...
@@ -67,4 +67,24 @@ describe Gitlab::API do
...
@@ -67,4 +67,24 @@ describe Gitlab::API do
end
end
end
end
end
end
describe
"POST /projects/:id/noteable/:noteable_id/notes"
do
context
"when noteable is an Issue"
do
it
"should create a new issue note"
do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
),
body:
'hi!'
response
.
status
.
should
==
201
json_response
[
'body'
].
should
==
'hi!'
json_response
[
'author'
][
'email'
].
should
==
user
.
email
end
end
context
"when noteable is a Snippet"
do
it
"should create a new snippet note"
do
post
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/notes"
,
user
),
body:
'hi!'
response
.
status
.
should
==
201
json_response
[
'body'
].
should
==
'hi!'
json_response
[
'author'
][
'email'
].
should
==
user
.
email
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