Commit 577fccab by Kevin Chugh

fixed tests

parent 87713149
...@@ -12,8 +12,8 @@ def remove_thread_flag(thread_id, user_id) ...@@ -12,8 +12,8 @@ def remove_thread_flag(thread_id, user_id)
remove_flag("/api/v1/threads/" + thread_id + "/abuse_unflags", user_id) remove_flag("/api/v1/threads/" + thread_id + "/abuse_unflags", user_id)
end end
def remove_comment_flag(thread_id, user_id) def remove_comment_flag(comment_id, user_id)
remove_flag("/api/v1/threads/" + comment_id + "/abuse_unflags", user_id) remove_flag("/api/v1/comments/" + comment_id + "/abuse_unflags", user_id)
end end
def create_flag(put_command, user_id) def create_flag(put_command, user_id)
...@@ -24,6 +24,14 @@ def create_flag(put_command, user_id) ...@@ -24,6 +24,14 @@ def create_flag(put_command, user_id)
end end
end end
def remove_flag(put_command, user_id)
if user_id.nil?
put put_command
else
put put_command, user_id: user_id
end
end
describe "app" do describe "app" do
describe "abuse" do describe "abuse" do
before(:each) { init_without_subscriptions } before(:each) { init_without_subscriptions }
...@@ -81,15 +89,18 @@ describe "app" do ...@@ -81,15 +89,18 @@ describe "app" do
describe "unflag a comment as abusive" do describe "unflag a comment as abusive" do
it "removes the user from the existing abuse_flaggers" do it "removes the user from the existing abuse_flaggers" do
comment = Comment.first comment = Comment.first
thread = comment.comment_thread create_comment_flag("#{comment.id}", User.first.id)
prev_abuse_flaggers = thread.abuse_flaggers
create_thread_flag("#{thread.id}", User.first.id) comment = Comment.first
prev_abuse_flaggers = comment.abuse_flaggers
prev_abuse_flaggers.should include User.first.id prev_abuse_flaggers.should include User.first.id
remove_thread_flag("#{thread.id}", User.first.id)
remove_comment_flag("#{comment.id}", User.first.id)
comment = Comment.find(comment.id) comment = Comment.find(comment.id)
comment.comment_thread.abuse_flaggers.length.should == prev_abuse_flaggers.length + 1 comment.abuse_flaggers.length.should == prev_abuse_flaggers.length - 1
prev_abuse_flaggers.should_not include? User.first.id comment.abuse_flaggers.to_a.should_not include User.first.id
end end
it "returns 400 when the thread does not exist" do it "returns 400 when the thread does not exist" do
remove_thread_flag("does_not_exist", User.first.id) remove_thread_flag("does_not_exist", User.first.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment