return the html_url with all stream item types in the api response
test plan: hit the /api/v1/users/self/activity_stream endpoint and verify the html urls returned for each type Change-Id: Ifc14b89586a324b026d744f6ba7813213d54f2b5 Reviewed-on: https://gerrit.instructure.com/10616 Reviewed-by: Brian Palmer <brianp@instructure.com> Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
parent
8e4b59a3ba
commit
dced1135c4
|
@ -253,6 +253,7 @@ class UsersController < ApplicationController
|
|||
# 'context_type': 'course', // course|group
|
||||
# 'course_id': 1,
|
||||
# 'group_id': null,
|
||||
# 'html_url': "http://..." // URL to the Canvas web UI for this stream item
|
||||
# }
|
||||
#
|
||||
# In addition, each item type has its own set of attributes available.
|
||||
|
|
|
@ -31,14 +31,17 @@ module Api::V1::StreamItem
|
|||
hash['message'] = data.body
|
||||
hash['type'] = data.type
|
||||
hash.merge!(context_data(data))
|
||||
context_type, context_id = stream_item.context_code.try(:split, '_', 2)
|
||||
|
||||
case data.type
|
||||
when 'DiscussionTopic', 'Announcement'
|
||||
hash['message'] = data.message
|
||||
if data.type == 'DiscussionTopic'
|
||||
hash['discussion_topic_id'] = data.id
|
||||
hash['html_url'] = send("#{context_type}_discussion_topic_url", context_id.to_i, data.id.to_i)
|
||||
else
|
||||
hash['announcement_id'] = data.id
|
||||
hash['html_url'] = send("#{context_type}_announcement_url", context_id.to_i, data.id.to_i)
|
||||
end
|
||||
hash['total_root_discussion_entries'] = data.total_root_discussion_entries
|
||||
hash['require_initial_post'] = data.require_initial_post
|
||||
|
@ -59,17 +62,19 @@ module Api::V1::StreamItem
|
|||
hash['conversation_id'] = data.id
|
||||
hash['private'] = data.private
|
||||
hash['participant_count'] = data.participant_count
|
||||
hash['html_url'] = conversation_url(data.id.to_i)
|
||||
when 'Message'
|
||||
hash['message_id'] = data.id
|
||||
# this type encompasses a huge number of different types of messages,
|
||||
# anything that gets send to communication channels
|
||||
hash['title'] = data.subject
|
||||
hash['notification_category'] = data.notification_category
|
||||
hash['url'] = data.url
|
||||
hash['html_url'] = hash['url'] = data.url
|
||||
when 'Submission'
|
||||
hash['title'] = data.assignment.try(:title)
|
||||
hash['grade'] = data.grade
|
||||
hash['score'] = data.score
|
||||
hash['html_url'] = course_assignment_submission_url(context_id, data.assignment.id, data.user_id)
|
||||
hash['submission_comments'] = data.submission_comments.map do |comment|
|
||||
{
|
||||
'body' => comment.formatted_body,
|
||||
|
@ -86,10 +91,12 @@ module Api::V1::StreamItem
|
|||
hash['web_conference_id'] = data.id
|
||||
hash['type'] = 'WebConference'
|
||||
hash['message'] = data.description
|
||||
hash['html_url'] = send("#{context_type}_conference_url", context_id.to_i, data.id.to_i) if context_type
|
||||
when /Collaboration/
|
||||
hash['collaboration_id'] = data.id
|
||||
# TODO: this type isn't even shown on the web activity stream yet
|
||||
hash['type'] = 'Collaboration'
|
||||
hash['html_url'] = send("#{context_type}_collaboration_url", context_id.to_i, data.id.to_i) if context_type
|
||||
else
|
||||
raise("Unexpected stream item type: #{data.type}")
|
||||
end
|
||||
|
|
|
@ -64,6 +64,7 @@ describe UsersController, :type => :integration do
|
|||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
'require_initial_post' => true,
|
||||
'user_has_posted' => true,
|
||||
'html_url' => "http://www.example.com/courses/#{@context.id}/discussion_topics/#{@topic.id}",
|
||||
|
||||
'total_root_discussion_entries' => 1,
|
||||
'root_discussion_entries' => [
|
||||
|
@ -127,6 +128,7 @@ describe UsersController, :type => :integration do
|
|||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
'require_initial_post' => nil,
|
||||
'user_has_posted' => nil,
|
||||
'html_url' => "http://www.example.com/courses/#{@context.id}/announcements/#{@a.id}",
|
||||
|
||||
'total_root_discussion_entries' => 1,
|
||||
'root_discussion_entries' => [
|
||||
|
@ -156,6 +158,7 @@ describe UsersController, :type => :integration do
|
|||
'message' => nil,
|
||||
|
||||
'private' => false,
|
||||
'html_url' => "http://www.example.com/conversations/#{@conversation.id}",
|
||||
|
||||
'participant_count' => 2
|
||||
}
|
||||
|
@ -176,6 +179,7 @@ describe UsersController, :type => :integration do
|
|||
|
||||
'notification_category' => 'TestImmediately',
|
||||
'url' => nil,
|
||||
'html_url' => nil,
|
||||
}]
|
||||
end
|
||||
|
||||
|
@ -199,6 +203,7 @@ describe UsersController, :type => :integration do
|
|||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
'grade' => '12',
|
||||
'score' => 12,
|
||||
'html_url' => "http://www.example.com/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@user.id}",
|
||||
|
||||
'assignment' => {
|
||||
'title' => 'assignment 1',
|
||||
|
@ -242,6 +247,7 @@ describe UsersController, :type => :integration do
|
|||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
'grade' => nil,
|
||||
'score' => nil,
|
||||
'html_url' => "http://www.example.com/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@user.id}",
|
||||
|
||||
'assignment' => {
|
||||
'title' => 'assignment 1',
|
||||
|
@ -283,6 +289,7 @@ describe UsersController, :type => :integration do
|
|||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
'grade' => '12',
|
||||
'score' => 12,
|
||||
'html_url' => "http://www.example.com/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@user.id}",
|
||||
|
||||
'assignment' => {
|
||||
'title' => 'assignment 1',
|
||||
|
@ -317,6 +324,9 @@ describe UsersController, :type => :integration do
|
|||
'title' => "hey",
|
||||
'message' => nil,
|
||||
'type' => 'Collaboration',
|
||||
'context_type' => 'Course',
|
||||
'course_id' => @course.id,
|
||||
'html_url' => "http://www.example.com/courses/#{@course.id}/collaborations/#{@collaboration.id}",
|
||||
'created_at' => StreamItem.last.created_at.as_json,
|
||||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
}]
|
||||
|
@ -326,7 +336,7 @@ describe UsersController, :type => :integration do
|
|||
WebConference.stubs(:plugins).returns(
|
||||
[OpenObject.new(:id => "big_blue_button", :settings => {:domain => "bbb.instructure.com", :secret_dec => "secret"}, :valid_settings? => true, :enabled? => true),]
|
||||
)
|
||||
@conference = BigBlueButtonConference.create!(:title => 'myconf', :user => @user, :description => 'mydesc', :conference_type => 'big_blue_button')
|
||||
@conference = BigBlueButtonConference.create!(:title => 'myconf', :user => @user, :description => 'mydesc', :conference_type => 'big_blue_button', :context => @course)
|
||||
json = api_call(:get, "/api/v1/users/activity_stream.json",
|
||||
{ :controller => "users", :action => "activity_stream", :format => 'json' })
|
||||
json.should == [{
|
||||
|
@ -335,6 +345,9 @@ describe UsersController, :type => :integration do
|
|||
'title' => "myconf",
|
||||
'type' => 'WebConference',
|
||||
'message' => 'mydesc',
|
||||
'context_type' => 'Course',
|
||||
'course_id' => @course.id,
|
||||
'html_url' => "http://www.example.com/courses/#{@course.id}/conferences/#{@conference.id}",
|
||||
'created_at' => StreamItem.last.created_at.as_json,
|
||||
'updated_at' => StreamItem.last.updated_at.as_json,
|
||||
}]
|
||||
|
|
|
@ -29,6 +29,7 @@ def valid_collaboration_attributes
|
|||
:collaboration_type => "value for collaboration_type",
|
||||
:document_id => "document:dc3pjs4r_3hhc6fvcc",
|
||||
:user_id => User.create!.id,
|
||||
:context => @course || course_model,
|
||||
:url => "value for url",
|
||||
:data => %{<?xml version="1.0" encoding="UTF-8"?>
|
||||
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:ns1="http://schemas.google.com/g/2005" xmlns:ns2="http://schemas.google.com/docs/2007">
|
||||
|
|
Loading…
Reference in New Issue