From 07893a2798373c82d32a04baccd5dafc6af06d3c Mon Sep 17 00:00:00 2001 From: wajeeha-khalid Date: Wed, 6 Apr 2016 16:43:59 +0500 Subject: [PATCH] return thread's last_activity_at in response object for thread endpoints --- models/comment_thread.rb | 2 +- spec/spec_helper.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/comment_thread.rb b/models/comment_thread.rb index 2ca168df440..d49331459c5 100644 --- a/models/comment_thread.rb +++ b/models/comment_thread.rb @@ -122,7 +122,7 @@ def endorsed? end def to_hash(params={}) - as_document.slice(*%w[thread_type title body course_id anonymous anonymous_to_peers commentable_id created_at updated_at at_position_list closed context]) + as_document.slice(*%w[thread_type title body course_id anonymous anonymous_to_peers commentable_id created_at updated_at at_position_list closed context last_activity_at]) .merge('id' => _id, 'user_id' => author_id, 'username' => author_username, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 04cdd4982c2..cab9804f364 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -162,7 +162,7 @@ def check_thread_result(user, thread, hash, is_json=false) expected_keys = %w(id thread_type title body course_id commentable_id created_at updated_at context) expected_keys += %w(anonymous anonymous_to_peers at_position_list closed user_id) expected_keys += %w(username votes abuse_flaggers tags type group_id pinned) - expected_keys += %w(comments_count unread_comments_count read endorsed) + expected_keys += %w(comments_count unread_comments_count read endorsed last_activity_at) # these keys are checked separately, when desired, using check_thread_response_paging. actual_keys = hash.keys - [ "children", "endorsed_responses", "non_endorsed_responses", "resp_skip", @@ -197,9 +197,11 @@ def check_thread_result(user, thread, hash, is_json=false) hash["id"].should == thread._id.to_s hash["created_at"].should == thread.created_at.utc.strftime("%Y-%m-%dT%H:%M:%SZ") hash["updated_at"].should == thread.updated_at.utc.strftime("%Y-%m-%dT%H:%M:%SZ") + hash["last_activity_at"].should == thread.last_activity_at.utc.strftime("%Y-%m-%dT%H:%M:%SZ") else hash["created_at"].should == thread.created_at hash["updated_at"].should == thread.updated_at + hash["last_activity_at"].should == thread.last_activity_at end if user.nil?