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
iv
gitlab-ce
Commits
1c5aa848
Commit
1c5aa848
authored
Nov 29, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: get a single note
parent
9a4974b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
lib/api/notes.rb
lib/api/notes.rb
+15
-0
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+20
-2
No files found.
lib/api/notes.rb
View file @
1c5aa848
...
@@ -33,6 +33,21 @@ module Gitlab
...
@@ -33,6 +33,21 @@ module Gitlab
@noteable
=
user_project
.
send
(
:"
#{
noteables_str
}
"
).
find
(
params
[
:"
#{
noteable_id_str
}
"
])
@noteable
=
user_project
.
send
(
:"
#{
noteables_str
}
"
).
find
(
params
[
:"
#{
noteable_id_str
}
"
])
present
paginate
(
@noteable
.
notes
),
with:
Entities
::
Note
present
paginate
(
@noteable
.
notes
),
with:
Entities
::
Note
end
end
# Get a single +noteable+ note
#
# Parameters:
# id (required) - The ID or code name of a project
# noteable_id (required) - The ID of an issue or snippet
# note_id (required) - The ID of a note
# Example Request:
# GET /projects/:id/issues/:noteable_id/notes/:note_id
# GET /projects/:id/snippets/:noteable_id/notes/:note_id
get
":id/
#{
noteables_str
}
/:
#{
noteable_id_str
}
/notes/:note_id"
do
@noteable
=
user_project
.
send
(
:"
#{
noteables_str
}
"
).
find
(
params
[
:"
#{
noteable_id_str
}
"
])
@note
=
@noteable
.
notes
.
find
(
params
[
:note_id
])
present
@note
,
with:
Entities
::
Note
end
end
end
end
end
end
end
...
...
spec/requests/api/notes_spec.rb
View file @
1c5aa848
...
@@ -32,7 +32,7 @@ describe Gitlab::API do
...
@@ -32,7 +32,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/noteable/:noteable_id/notes"
do
describe
"GET /projects/:id/noteable/:noteable_id/notes"
do
context
"when noteable is an Issue"
do
context
"when noteable is an Issue"
do
it
"should return an array of notes"
do
it
"should return an array of
issue
notes"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
...
@@ -41,7 +41,7 @@ describe Gitlab::API do
...
@@ -41,7 +41,7 @@ describe Gitlab::API do
end
end
context
"when noteable is a Snippet"
do
context
"when noteable is a Snippet"
do
it
"should return an array of notes"
do
it
"should return an array of
snippet
notes"
do
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/notes"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/notes"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
...
@@ -49,4 +49,22 @@ describe Gitlab::API do
...
@@ -49,4 +49,22 @@ describe Gitlab::API do
end
end
end
end
end
end
describe
"GET /projects/:id/noteable/:noteable_id/notes/:note_id"
do
context
"when noteable is an Issue"
do
it
"should return an issue note by id"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes/
#{
issue_note
.
id
}
"
,
user
)
response
.
status
.
should
==
200
json_response
[
'body'
].
should
==
issue_note
.
note
end
end
context
"when noteable is a Snippet"
do
it
"should return a snippet note by id"
do
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
/notes/
#{
snippet_note
.
id
}
"
,
user
)
response
.
status
.
should
==
200
json_response
[
'body'
].
should
==
snippet_note
.
note
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