fixed the notifications to call the base_class
This commit is contained in:
parent
c1844c9be2
commit
3b2d323448
4 changed files with 5 additions and 8 deletions
|
|
@ -22,6 +22,6 @@ class Mention < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_notification
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Notification < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
def self.concatenate_or_create(recipient, target, actor, action)
|
def self.concatenate_or_create(recipient, target, actor, action)
|
||||||
if n = Notification.where(:target_id => target.id,
|
if n = Notification.where(:target_id => target.id,
|
||||||
:target_type => target.type,
|
:target_type => target.class.base_class,
|
||||||
:action => action,
|
:action => action,
|
||||||
:recipient_id => recipient.id).first
|
:recipient_id => recipient.id).first
|
||||||
unless n.actors.include?(actor)
|
unless n.actors.include?(actor)
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,6 @@ describe Mention do
|
||||||
@sm = Factory(:status_message)
|
@sm = Factory(:status_message)
|
||||||
@m = Mention.create(:person => @user.person, :post=> @sm)
|
@m = Mention.create(:person => @user.person, :post=> @sm)
|
||||||
|
|
||||||
|
|
||||||
pp Notification.first
|
|
||||||
|
|
||||||
lambda{
|
lambda{
|
||||||
@m.destroy
|
@m.destroy
|
||||||
}.should change(Notification, :count).by(-1)
|
}.should change(Notification, :count).by(-1)
|
||||||
|
|
|
||||||
|
|
@ -92,16 +92,16 @@ describe Notification do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates the notification with a more people if one already exists" do
|
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
|
end
|
||||||
|
|
||||||
it 'handles double comments from the same person without raising' do
|
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
|
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
|
end
|
||||||
|
|
||||||
it 'marks the notification as unread' do
|
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.unread = false
|
||||||
note.save
|
note.save
|
||||||
lambda {
|
lambda {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue