Skip to content

Commit

Permalink
Merge pull request #183 from edx/jia/TNL-3818
Browse files Browse the repository at this point in the history
TNL-3818 return thread's last_activity_at in response object for thread endpoints
  • Loading branch information
wajeeha-khalid committed Apr 13, 2016
2 parents 39cc391 + 07893a2 commit 26adedc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion models/comment_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit 26adedc

Please sign in to comment.