diff --git a/app/models/stream_item.rb b/app/models/stream_item.rb index 5281353f50b..ee1f6e51dd2 100644 --- a/app/models/stream_item.rb +++ b/app/models/stream_item.rb @@ -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 diff --git a/spec/models/stream_item_spec.rb b/spec/models/stream_item_spec.rb index 0c65cf90dde..2f6c9e89fc7 100644 --- a/spec/models/stream_item_spec.rb +++ b/spec/models/stream_item_spec.rb @@ -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 diff --git a/spec/selenium/dashboard_spec.rb b/spec/selenium/dashboard_spec.rb index 65d2829054c..d5216437024 100644 --- a/spec/selenium/dashboard_spec.rb +++ b/spec/selenium/dashboard_spec.rb @@ -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