fix notifications showing up in course streams

They weren't using the course/group for the context_code, so they would
only show up in the global stream.

Note this doesn't fix existing stream items, just new ones going
forward.

test plan: add an assignment or generate any other sort of notification
that gets sent to the stream. verify that it shows up both on the
dashboard and on the individual course/group stream.

Change-Id: Icfa1430545e80c575c76960a7267ae1d7d8ddad4
Reviewed-on: https://gerrit.instructure.com/10842
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
Brian Palmer 2012-05-17 12:50:13 -06:00
parent aafb0e247f
commit 5b04db4372
3 changed files with 16 additions and 2 deletions

View File

@ -146,7 +146,9 @@ class StreamItem < ActiveRecord::Base
when Message
res = object.attributes
res['notification_category'] = object.notification_display_category
if object.asset_context_type
if !object.context.is_a?(Context) && object.context.respond_to?(:context) && object.context.context.is_a?(Context)
self.context_code = object.context.context.asset_string
elsif object.asset_context_type
self.context_code = "#{object.asset_context_type.underscore}_#{object.asset_context_id}"
end
when Submission

View File

@ -29,4 +29,16 @@ describe StreamItem do
data.type.should == 'DiscussionTopic'
data.user_id.should be_nil
end
it "should prefer a Context for Message stream item context" do
notification_model(:name => 'Assignment Created')
course_with_student(:active_all => true)
assignment_model(:course => @course)
item = @user.stream_items.first
item.data.notification_name.should == 'Assignment Created'
item.context_code.should == @course.asset_string
course_items = @user.recent_stream_items(:contexts => [@course])
course_items.should == [item]
end
end

View File

@ -88,7 +88,7 @@ describe "dashboard" do
# appointment group publish and update notifications
find_all_with_jquery("div.communication_message.message_appointment_group_#{@appointment_group.id}").size.should == 2
# signup notification
find_all_with_jquery("div.communication_message.message_calendar_event_#{@event.id}").size.should == 1
find_all_with_jquery("div.communication_message.message_group_#{@group.id}").size.should == 1
end
it "should display assignment in to do list" do