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
8e94bfd8
Commit
8e94bfd8
authored
Jul 26, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec for votes; cover more errors
parent
3e1eb13a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
app.rb
+4
-0
spec/vote_spec.rb
+22
-0
No files found.
app.rb
View file @
8e94bfd8
...
...
@@ -151,6 +151,10 @@ error BSON::InvalidObjectId do
error
400
,
"requested object not found"
end
error
Mongoid
::
Errors
::
DocumentNotFound
do
error
400
,
"requested object not found"
end
error
ValueError
do
error
400
,
env
[
'sinatra.error'
].
message
end
spec/vote_spec.rb
View file @
8e94bfd8
...
...
@@ -60,6 +60,20 @@ describe "app" do
thread
.
up_votes_count
.
should
==
prev_up_votes
-
1
thread
.
down_votes_count
.
should
==
prev_down_votes
+
1
end
it
"returns 400 when the thread does not exist"
do
put
"/api/v1/threads/does_not_exist/votes"
,
user_id:
User
.
first
.
id
,
value:
"down"
last_response
.
status
.
should
==
400
end
it
"returns 400 when user_id is not provided"
do
put
"/api/v1/threads/
#{
CommentThread
.
first
.
id
}
/votes"
,
value:
"down"
last_response
.
status
.
should
==
400
end
it
"returns 400 when value is not provided or invalid"
do
put
"/api/v1/threads/
#{
CommentThread
.
first
.
id
}
/votes"
,
user_id:
User
.
first
.
id
last_response
.
status
.
should
==
400
put
"/api/v1/threads/
#{
CommentThread
.
first
.
id
}
/votes"
,
user_id:
User
.
first
.
id
,
value:
"superdown"
last_response
.
status
.
should
==
400
end
end
describe
"DELETE /api/v1/threads/:thread_id/votes"
do
it
"unvote on the thread"
do
...
...
@@ -72,6 +86,14 @@ describe "app" do
thread
.
up_votes_count
.
should
==
prev_up_votes
-
1
thread
.
down_votes_count
.
should
==
prev_down_votes
end
it
"returns 400 when the comment does not exist"
do
delete
"/api/v1/threads/does_not_exist/votes"
,
user_id:
User
.
first
.
id
last_response
.
status
.
should
==
400
end
it
"returns 400 when user_id is not provided"
do
delete
"/api/v1/threads/
#{
CommentThread
.
first
.
id
}
/votes"
last_response
.
status
.
should
==
400
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