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
b9a8f441
Commit
b9a8f441
authored
Apr 23, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unflag thread test
parent
8a4f73f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
6 deletions
+36
-6
spec/api/abuse_spec.rb
+36
-6
No files found.
spec/api/abuse_spec.rb
View file @
b9a8f441
require
'spec_helper'
def
create_comment_flag
(
comment_id
,
user_id
)
create_flag
(
"/api/v1/comments/"
+
comment_id
+
"/abuse_flag
s
"
,
user_id
)
create_flag
(
"/api/v1/comments/"
+
comment_id
+
"/abuse_flag"
,
user_id
)
end
def
create_thread_flag
(
thread_id
,
user_id
)
create_flag
(
"/api/v1/threads/"
+
thread_id
+
"/abuse_flag
s
"
,
user_id
)
create_flag
(
"/api/v1/threads/"
+
thread_id
+
"/abuse_flag"
,
user_id
)
end
def
remove_thread_flag
(
thread_id
,
user_id
)
remove_flag
(
"/api/v1/threads/"
+
thread_id
+
"/abuse_unflag
s
"
,
user_id
)
remove_flag
(
"/api/v1/threads/"
+
thread_id
+
"/abuse_unflag"
,
user_id
)
end
def
remove_comment_flag
(
comment_id
,
user_id
)
remove_flag
(
"/api/v1/comments/"
+
comment_id
+
"/abuse_unflag
s
"
,
user_id
)
remove_flag
(
"/api/v1/comments/"
+
comment_id
+
"/abuse_unflag"
,
user_id
)
end
def
create_flag
(
put_command
,
user_id
)
if
user_id
.
nil?
if
user_id
.
nil?
put
put_command
else
put
put_command
,
user_id:
user_id
...
...
@@ -25,7 +25,7 @@ def create_flag(put_command, user_id)
end
def
remove_flag
(
put_command
,
user_id
)
if
user_id
.
nil?
if
user_id
.
nil?
put
put_command
else
put
put_command
,
user_id:
user_id
...
...
@@ -103,6 +103,36 @@ describe "app" do
comment
.
abuse_flaggers
.
to_a
.
should_not
include
User
.
first
.
id
end
it
"returns 400 when the thread does not exist"
do
remove_comment_flag
(
"does_not_exist"
,
User
.
first
.
id
)
last_response
.
status
.
should
==
400
end
it
"returns 400 when user_id is not provided"
do
remove_comment_flag
(
"
#{
Comment
.
first
.
comment_thread
.
id
}
"
,
nil
)
last_response
.
status
.
should
==
400
end
#Would like to test the output of to_hash, but not sure how to deal with a Moped::BSON::Document object
#it "has a correct hash" do
# create_thread_flag("#{Comment.first.comment_thread.id}", User.first.id)
# Comment.first.comment_thread.to_hash
#end
end
describe
"unflag a thread as abusive"
do
it
"removes the user from the existing abuse_flaggers"
do
thread
=
CommentThread
.
first
create_thread_flag
(
"
#{
thread
.
id
}
"
,
User
.
first
.
id
)
thread
=
CommentThread
.
first
prev_abuse_flaggers
=
thread
.
abuse_flaggers
prev_abuse_flaggers
.
should
include
User
.
first
.
id
remove_thread_flag
(
"
#{
thread
.
id
}
"
,
User
.
first
.
id
)
thread
=
CommentThread
.
find
(
thread
.
id
)
thread
.
abuse_flaggers
.
length
.
should
==
prev_abuse_flaggers
.
length
-
1
thread
.
abuse_flaggers
.
to_a
.
should_not
include
User
.
first
.
id
end
it
"returns 400 when the thread does not exist"
do
remove_thread_flag
(
"does_not_exist"
,
User
.
first
.
id
)
last_response
.
status
.
should
==
400
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