spec for not raising on already existant actor
This commit is contained in:
parent
cfef9a747e
commit
ac50a0119a
2 changed files with 22 additions and 9 deletions
|
|
@ -48,11 +48,13 @@ private
|
||||||
if n = Notification.where(:target_id => target.id,
|
if n = Notification.where(:target_id => target.id,
|
||||||
:action => action,
|
:action => action,
|
||||||
:recipient_id => recipient.id).first
|
:recipient_id => recipient.id).first
|
||||||
n.actors << actor unless n.actors.include?(actor)
|
unless n.actors.include?(actor)
|
||||||
n.save!
|
n.actors << actor
|
||||||
|
n.save!
|
||||||
|
end
|
||||||
n
|
n
|
||||||
else
|
else
|
||||||
n = make_notification(recipient, target, actor, action)
|
make_notification(recipient, target, actor, action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,23 @@ describe Notification do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates the notification with a more people if one already exists" do
|
context 'multiple people' do
|
||||||
@user3 = bob
|
|
||||||
sm = @user3.post(:status_message, :message => "comment!", :to => :all)
|
before do
|
||||||
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => sm)).receive_object
|
@user3 = bob
|
||||||
Postzord::Receiver.new(@user3, :person => @user.person, :object => @user.comment("hey", :on => sm)).receive_object
|
@sm = @user3.post(:status_message, :message => "comment!", :to => :all)
|
||||||
Notification.where(:recipient_id => @user3.id,:target_id => sm.id).first.actors.count.should == 2
|
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => @sm)).receive_object
|
||||||
|
Postzord::Receiver.new(@user3, :person => @user.person, :object => @user.comment("hey", :on => @sm)).receive_object
|
||||||
|
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
|
||||||
|
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
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue