Commit 03ddd086 by Kevin Chugh

add flagging test to notifications

parent 14e78165
development2:
development:
sessions:
default:
database: cs_comments_service_development
hosts:
- localhost:27017
development:
sessions:
default:
database: comments-prod-clone
hosts:
- charlotte.mongohq.com:10035
username: kevinchugh@edx.org
password: lewis123
test:
sessions:
default:
......
......@@ -42,7 +42,6 @@ describe "app" do
end
end
#now make sure the threads are a subset of the user's subscriptions
puts user.id
subscriptions = Subscription.where(:subscriber_id => user.id.to_s)
subscribed_thread_ids = subscriptions.collect{|s| s.source_id}
......@@ -50,6 +49,39 @@ describe "app" do
end
it "returns only unflagged threads" do
start_time = Date.today - 400.days
end_time = Time.now
user = User.find Subscription.first.subscriber_id
post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id
last_response.should be_ok
payload = JSON.parse last_response.body
courses = payload[user.id.to_s]
thread_ids = []
courses.each do |k,v|
v.each do |kk,vv|
thread_ids << kk
end
end
#now flag the first thread
thread = CommentThread.find thread_ids.first
thread.historical_abuse_flaggers << ["1"]
post "/api/v1/notifications", from: CGI::escape(start_time.to_s), to: CGI::escape(end_time.to_s), user_ids: user.id
last_response.should be_ok
payload = JSON.parse last_response.body
courses = payload[user.id.to_s]
new_thread_ids = []
courses.each do |k,v|
v.each do |kk,vv|
new_thread_ids << kk
end
end
(new_thread_ids.include? thread.id).should == false
end
end
end
end
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