fixed the notifications to call the base_class

This commit is contained in:
zhitomirskiyi 2011-02-11 11:45:28 -08:00
parent c1844c9be2
commit 3b2d323448
4 changed files with 5 additions and 8 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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 {