Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
1d713308
Commit
1d713308
authored
Mar 04, 2014
by
jsa
Committed by
Greg Price
Apr 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return 404 instead of 400 when thread not found
Co-authored-by: Greg Price <gprice@edx.org>
parent
64c08fb0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
api/comment_threads.rb
+5
-1
spec/api/comment_thread_spec.rb
+8
-6
No files found.
api/comment_threads.rb
View file @
1d713308
...
...
@@ -11,7 +11,11 @@ get "#{APIPREFIX}/threads" do # retrieve threads by course
end
get
"
#{
APIPREFIX
}
/threads/:thread_id"
do
|
thread_id
|
thread
=
CommentThread
.
find
(
thread_id
)
begin
thread
=
CommentThread
.
find
(
thread_id
)
rescue
Mongoid
::
Errors
::
DocumentNotFound
error
404
,
[
t
(
:requested_object_not_found
)].
to_json
end
if
params
[
"user_id"
]
and
bool_mark_as_read
user
=
User
.
only
([
:id
,
:username
,
:read_states
]).
find_by
(
external_id:
params
[
"user_id"
])
...
...
spec/api/comment_thread_spec.rb
View file @
1d713308
...
...
@@ -375,12 +375,14 @@ describe "app" do
check_thread_response_paging_json
(
thread
,
parse
(
last_response
.
body
))
end
it
"returns 400 when the thread does not exist"
do
get
"/api/v1/threads/does_not_exist"
last_response
.
status
.
should
==
400
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
get
"/api/v1/threads/5016a3caec5eb9a12300000b1"
last_response
.
status
.
should
==
400
it
"returns 404 when the thread does not exist"
do
thread
=
CommentThread
.
first
path
=
"/api/v1/threads/
#{
thread
.
id
}
"
get
path
last_response
.
should
be_ok
thread
.
destroy
get
path
last_response
.
status
.
should
==
404
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
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