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
4efc1c81
Commit
4efc1c81
authored
May 22, 2013
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify abuse specs to work with identity map.
parent
6074efe7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
api/flags.rb
+1
-2
spec/api/abuse_spec.rb
+12
-7
No files found.
api/flags.rb
View file @
4efc1c81
...
...
@@ -12,4 +12,4 @@ end
put
"
#{
APIPREFIX
}
/comments/:comment_id/abuse_unflag"
do
|
comment_id
|
un_flag_as_abuse
comment
end
\ No newline at end of file
end
spec/api/abuse_spec.rb
View file @
4efc1c81
...
...
@@ -38,11 +38,14 @@ describe "app" do
describe
"flag a comment as abusive"
do
it
"create or update the abuse_flags on the comment"
do
comment
=
Comment
.
first
prev_abuse_flaggers
=
comment
.
abuse_flaggers
# We get the count rather than just keeping the array, because the array
# will update as the Comment updates since the IdentityMap is enabled.
prev_abuse_flaggers_count
=
comment
.
abuse_flaggers
.
length
create_comment_flag
(
"
#{
comment
.
id
}
"
,
User
.
first
.
id
)
comment
=
Comment
.
find
(
comment
.
id
)
comment
.
abuse_flaggers
.
length
.
should
==
prev_abuse_flaggers
.
length
+
1
comment
.
abuse_flaggers
.
count
.
should
==
prev_abuse_flaggers_count
+
1
# verify that the thread doesn't automatically get flagged
comment
.
comment_thread
.
abuse_flaggers
.
length
.
should
==
0
end
...
...
@@ -64,11 +67,11 @@ describe "app" do
it
"create or update the abuse_flags on the comment"
do
comment
=
Comment
.
first
thread
=
comment
.
comment_thread
prev_abuse_flaggers
=
thread
.
abuse_flaggers
prev_abuse_flaggers
_count
=
thread
.
abuse_flaggers
.
count
create_thread_flag
(
"
#{
thread
.
id
}
"
,
User
.
first
.
id
)
comment
=
Comment
.
find
(
comment
.
id
)
comment
.
comment_thread
.
abuse_flaggers
.
length
.
should
==
prev_abuse_flaggers
.
length
+
1
comment
.
comment_thread
.
abuse_flaggers
.
count
.
should
==
prev_abuse_flaggers_count
+
1
# verify that the comment doesn't automatically get flagged
comment
.
abuse_flaggers
.
length
.
should
==
0
end
...
...
@@ -92,14 +95,15 @@ describe "app" do
create_comment_flag
(
"
#{
comment
.
id
}
"
,
User
.
first
.
id
)
comment
=
Comment
.
first
prev_abuse_flaggers
=
comment
.
abuse_flaggers
prev_abuse_flaggers
=
comment
.
abuse_flaggers
prev_abuse_flaggers_count
=
prev_abuse_flaggers
.
count
prev_abuse_flaggers
.
should
include
User
.
first
.
id
remove_comment_flag
(
"
#{
comment
.
id
}
"
,
User
.
first
.
id
)
comment
=
Comment
.
find
(
comment
.
id
)
comment
.
abuse_flaggers
.
length
.
should
==
prev_abuse_flaggers
.
length
-
1
comment
.
abuse_flaggers
.
count
.
should
==
prev_abuse_flaggers_count
-
1
comment
.
abuse_flaggers
.
to_a
.
should_not
include
User
.
first
.
id
end
it
"returns 400 when the thread does not exist"
do
...
...
@@ -123,13 +127,14 @@ describe "app" do
thread
=
CommentThread
.
first
prev_abuse_flaggers
=
thread
.
abuse_flaggers
prev_abuse_flaggers_count
=
prev_abuse_flaggers
.
count
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
.
count
.
should
==
prev_abuse_flaggers_count
-
1
thread
.
abuse_flaggers
.
to_a
.
should_not
include
User
.
first
.
id
end
it
"returns 400 when the thread does not exist"
do
...
...
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