diff --git a/spec/api/comment_thread_spec.rb b/spec/api/comment_thread_spec.rb index d6a2c9f6b5..daf99af631 100644 --- a/spec/api/comment_thread_spec.rb +++ b/spec/api/comment_thread_spec.rb @@ -673,13 +673,6 @@ def thread_result(id, params) end end - it "handles responses when merge_question_type_responses param is given" do - @threads.each do |n, thread| - res = thread_result thread.id, {} - check_thread_response_paging_json thread, res, 0, nil, false, true - end - end - it "skips the specified number of responses" do @threads.each do |n, thread| res = thread_result thread.id, {:resp_skip => 1} @@ -704,6 +697,41 @@ def thread_result(id, params) end end + context "response pagination" do + def thread_result(id, params) + get "/api/v1/threads/#{id}", params + expect(last_response).to be_ok + parse(last_response.body) + end + + it "handles responses when merge_question_type_responses=true" do + User.all.delete + Content.all.delete + @user = create_test_user(999) + @threads = {} + @comments = {} + [201, 10, 3, 2, 1, 0].each do |n| + thread_key = "t#{n}" + thread = make_thread(@user, thread_key, DFLT_COURSE_ID, "pdq", :question) + @threads[n] = thread + n.times do |i| + # generate n responses in this thread + comment_key = "#{thread_key} r#{i}" + comment = make_comment(@user, thread, comment_key) + 2.times do |j| + subcomment_key = "#{comment_key} c#{j}" + subcomment = make_comment(@user, comment, subcomment_key) + end + @comments[comment_key] = comment + end + end + @threads.each do |n, thread| + res = thread_result thread.id, {:merge_question_type_responses => true} + check_thread_response_paging_json thread, res, 0, nil, false, false, true + end + end + end + describe "PUT /api/v1/threads/:thread_id" do before(:each) { init_without_subscriptions }