MA-1359 returned resp_total for existing question and new thread
This commit is contained in:
Родитель
2e84f82650
Коммит
52b40cf4f0
|
@ -47,6 +47,8 @@ post "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
|
|||
else
|
||||
user.subscribe(thread) if bool_auto_subscribe
|
||||
presenter = ThreadPresenter.factory(thread, nil)
|
||||
presenter.to_hash.to_json
|
||||
thread = presenter.to_hash
|
||||
thread["resp_total"] = 0
|
||||
thread.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,6 +51,7 @@ class ThreadPresenter
|
|||
h["endorsed_responses"] = endorsed_response_info["responses"]
|
||||
h["non_endorsed_responses"] = non_endorsed_response_info["responses"]
|
||||
h["non_endorsed_resp_total"] = non_endorsed_response_info["response_count"]
|
||||
h["resp_total"] = non_endorsed_response_info["response_count"] + endorsed_response_info["response_count"]
|
||||
when "discussion"
|
||||
response_info = get_paged_merged_responses(@thread._id, responses, resp_skip, resp_limit)
|
||||
h["children"] = response_info["responses"]
|
||||
|
|
|
@ -102,6 +102,7 @@ describe "app" do
|
|||
result["read"].should == false
|
||||
result["unread_comments_count"].should == 0
|
||||
result["endorsed"].should == false
|
||||
result["resp_total"].should == 0
|
||||
CommentThread.count.should == old_count + 1
|
||||
thread = CommentThread.where(title: "Interesting question").first
|
||||
thread.should_not be_nil
|
||||
|
|
|
@ -341,6 +341,9 @@ def check_question_response_paging(thread, hash, resp_skip=0, resp_limit=nil, is
|
|||
hash["non_endorsed_responses"].each_with_index do |response_hash, i|
|
||||
check_comment(expected_non_endorsed_responses[i], response_hash, is_json)
|
||||
end
|
||||
total_responses = endorsed_responses.length + non_endorsed_responses.length
|
||||
hash["resp_total"].should == total_responses
|
||||
|
||||
hash["resp_skip"].to_i.should == resp_skip
|
||||
if resp_limit.nil?
|
||||
hash["resp_limit"].should be_nil
|
||||
|
|
Загрузка…
Ссылка в новой задаче