Commit d2e14133 by Greg Price

Filter commentable queries by course_id

Bug: TNL-207
parent d26bc6b7
...@@ -5,6 +5,9 @@ end ...@@ -5,6 +5,9 @@ end
get "#{APIPREFIX}/:commentable_id/threads" do |commentable_id| get "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
threads = Content.where({"_type" => "CommentThread", "commentable_id" => commentable_id}) threads = Content.where({"_type" => "CommentThread", "commentable_id" => commentable_id})
if params["course_id"]
threads = threads.where({"course_id" => params["course_id"]})
end
handle_threads_query( handle_threads_query(
threads, threads,
......
...@@ -32,6 +32,13 @@ describe "app" do ...@@ -32,6 +32,13 @@ describe "app" do
threads.index{|c| c["body"] == "can anyone help me?"}.should_not be_nil threads.index{|c| c["body"] == "can anyone help me?"}.should_not be_nil
threads.index{|c| c["body"] == "it is unsolvable"}.should_not be_nil threads.index{|c| c["body"] == "it is unsolvable"}.should_not be_nil
end end
it "filters by course_id" do
course1_threads = thread_result "question_1", course_id: "1"
course1_threads.length.should == 1
course2_threads = thread_result "question_1", course_id: "2"
course2_threads.length.should == 1
course1_threads.should_not == course2_threads
end
it "filters by group_id" do it "filters by group_id" do
group_thread = Commentable.find("question_1").comment_threads.first group_thread = Commentable.find("question_1").comment_threads.first
threads = thread_result "question_1", group_id: 42 threads = thread_result "question_1", group_id: 42
......
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