Commit 14e78165 by Kevin Chugh

add thread subset test

parent a312ab8d
development:
development2:
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:
......
......@@ -26,6 +26,30 @@ describe "app" do
last_response.should be_ok
last_response.body.to_s.include?(dummy).should == true
end
it "returns only threads subscribed to by user" 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 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}
(subscribed_thread_ids.to_set.superset? thread_ids.to_set).should == true
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