Skip to content

Commit

Permalink
test: fixed failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ayesha-waris committed Mar 1, 2024
1 parent db49135 commit 9921392
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions spec/api/comment_thread_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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 }
Expand Down

0 comments on commit 9921392

Please sign in to comment.