-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: updated api to allow ordering on endorsed status #425
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
require 'spec_helper' | ||
|
||
describe ThreadPresenter do | ||
|
||
context "#to_hash" do | ||
let(:default_resp_limit) { CommentService.config["thread_response_default_size"] } | ||
|
||
|
@@ -167,6 +167,15 @@ def random_flag_abuses!(comment) | |
end | ||
end | ||
|
||
it "handles merge_question_type_responses=true" do | ||
@threads_with_num_comments.each do |thread, num_comments| | ||
is_endorsed = num_comments > 0 && endorse_responses | ||
hash = ThreadPresenter.new(thread, @reader, false, num_comments, is_endorsed, nil).to_hash(true, 0, default_resp_limit, true, false, true, true) | ||
check_thread_result(@reader, thread, hash) | ||
check_thread_response_paging(thread, hash, 0, default_resp_limit, false, false, true, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the same check we have for before this new param was added! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
end | ||
|
||
it "handles reversed_order and recursive with skip and limit" do | ||
@threads_with_num_comments.each do |thread, num_comments| | ||
is_endorsed = num_comments > 0 && endorse_responses | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,12 +254,12 @@ def check_unread_thread_result_json(thread, json_response) | |
check_thread_result(nil, thread, json_response, true) | ||
end | ||
|
||
def check_thread_response_paging(thread, hash, resp_skip=0, resp_limit=nil, is_json=false, recursive=false, reverse_order=false) | ||
case thread.thread_type | ||
when "discussion" | ||
check_discussion_response_paging(thread, hash, resp_skip, resp_limit, is_json, recursive, reverse_order) | ||
when "question" | ||
check_question_response_paging(thread, hash, resp_skip, resp_limit, is_json, recursive, reverse_order) | ||
def check_thread_response_paging(thread, hash, resp_skip=0, resp_limit=nil, is_json=false, recursive=false, reverse_order=false, merge_question_type_responses=false) | ||
|
||
if (thread.thread_type == "discussion" || (thread.thread_type == "question" && merge_question_type_responses)) | ||
check_discussion_response_paging(thread, hash, resp_skip, resp_limit, is_json, recursive, reverse_order) | ||
else | ||
check_question_response_paging(thread, hash, resp_skip, resp_limit, is_json, recursive, reverse_order) | ||
saadyousafarbi marked this conversation as resolved.
Show resolved
Hide resolved
saadyousafarbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end | ||
|
||
|
@@ -333,8 +333,8 @@ def check_question_response_paging(thread, hash, resp_skip=0, resp_limit=nil, is | |
end | ||
end | ||
|
||
def check_thread_response_paging_json(thread, hash, resp_skip=0, resp_limit=nil, recursive=false, reverse_order=false) | ||
check_thread_response_paging(thread, hash, resp_skip, resp_limit, true, recursive, reverse_order) | ||
def check_thread_response_paging_json(thread, hash, resp_skip=0, resp_limit=nil, recursive=false, reverse_order=false, merge_question_type_responses=false) | ||
check_thread_response_paging(thread, hash, resp_skip, resp_limit, true, recursive, reverse_order, merge_question_type_responses) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this new param passed is not taken as an input for the function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This parameter is intended to be used exclusively in the case of question-type threads. If provided, it serves to check whether the generated response matches that of a discussion-type thread." |
||
end | ||
|
||
# general purpose factory helpers | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this check mean now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The objective of this pull request (PR) is to ensure that the API responses for discussion type threads and question type threads are consistent. To achieve this, the check is to verify if the merge_question_type_responses parameter is present in the API call and if the thread type is a question. If both conditions are met, the API response for question type threads should match that of discussion type threads.