diff --git a/app/models/mention.rb b/app/models/mention.rb index 7c9deb3be..42992bd5f 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -22,6 +22,6 @@ class Mention < ActiveRecord::Base end def delete_notification - Notification.where(:target_type => self.class, :target_id => self.id).delete_all + Notification.where(:target_type => self.class.name, :target_id => self.id).delete_all end end diff --git a/app/models/notification.rb b/app/models/notification.rb index 473005b85..b1431cffd 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -48,7 +48,7 @@ class Notification < ActiveRecord::Base private def self.concatenate_or_create(recipient, target, actor, action) if n = Notification.where(:target_id => target.id, - :target_type => target.type, + :target_type => target.class.base_class, :action => action, :recipient_id => recipient.id).first unless n.actors.include?(actor) diff --git a/spec/models/mention_spec.rb b/spec/models/mention_spec.rb index 7f5b27644..bd72f778b 100644 --- a/spec/models/mention_spec.rb +++ b/spec/models/mention_spec.rb @@ -36,9 +36,6 @@ describe Mention do @sm = Factory(:status_message) @m = Mention.create(:person => @user.person, :post=> @sm) - - pp Notification.first - lambda{ @m.destroy }.should change(Notification, :count).by(-1) diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index e8ececfb0..17f7d221a 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -92,16 +92,16 @@ describe Notification do end it "updates the notification with a more people if one already exists" do - Notification.where(:recipient_id => @user3.id,:target_id => @sm.id).first.actors.count.should == 2 + Notification.where(:recipient_id => @user3.id, :target_type => @sm.class.base_class, :target_id => @sm.id).first.actors.count.should == 2 end it 'handles double comments from the same person without raising' do Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => @sm)).receive_object - Notification.where(:recipient_id => @user3.id,:target_id => @sm.id).first.actors.count.should == 2 + Notification.where(:recipient_id => @user3.id, :target_type => @sm.class.base_class, :target_id => @sm.id).first.actors.count.should == 2 end it 'marks the notification as unread' do - note = Notification.where(:recipient_id => @user3.id,:target_id => @sm.id).first + note = Notification.where(:recipient_id => @user3.id,:target_type => @sm.class.base_class, :target_id => @sm.id).first note.unread = false note.save lambda {