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
88abdd8a
Commit
88abdd8a
authored
Mar 17, 2014
by
jsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use 404 when trying to GET a nonexistent user
JIRA: FOR-522
parent
53a2390b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
api/users.rb
+5
-1
spec/api/user_spec.rb
+14
-0
No files found.
api/users.rb
View file @
88abdd8a
...
...
@@ -13,7 +13,11 @@ post "#{APIPREFIX}/users" do
end
get
"
#{
APIPREFIX
}
/users/:user_id"
do
|
user_id
|
user
.
to_hash
(
complete:
bool_complete
,
course_id:
params
[
"course_id"
]).
to_json
begin
user
.
to_hash
(
complete:
bool_complete
,
course_id:
params
[
"course_id"
]).
to_json
rescue
Mongoid
::
Errors
::
DocumentNotFound
error
404
end
end
get
"
#{
APIPREFIX
}
/users/:user_id/active_threads"
do
|
user_id
|
...
...
spec/api/user_spec.rb
View file @
88abdd8a
...
...
@@ -47,6 +47,20 @@ describe "app" do
last_response
.
status
.
should
==
400
end
end
describe
"GET /api/v1/users/:user_id"
do
it
"returns user information"
do
get
"/api/v1/users/1"
last_response
.
status
.
should
==
200
res
=
parse
(
last_response
.
body
)
user1
=
User
.
find_by
(
"1"
)
res
[
"external_id"
].
should
==
user1
.
external_id
res
[
"username"
].
should
==
user1
.
username
end
it
"returns 404 if user does not exist"
do
get
"/api/v1/users/3"
last_response
.
status
.
should
==
404
end
end
describe
"GET /api/v1/users/:user_id/active_threads"
do
before
(
:each
)
{
setup_10_threads
}
...
...
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