adding basic notification class
This commit is contained in:
parent
bd31ff3ee3
commit
a7d36615e6
6 changed files with 65 additions and 3 deletions
18
app/models/notification.rb
Normal file
18
app/models/notification.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
#
|
||||||
|
class Notification
|
||||||
|
include MongoMapper::Document
|
||||||
|
|
||||||
|
|
||||||
|
key :object_id, ObjectId
|
||||||
|
key :kind, String
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :person
|
||||||
|
|
||||||
|
timestamps!
|
||||||
|
|
||||||
|
attr_accessible :object_id, :kind, :user, :person
|
||||||
|
end
|
||||||
BIN
dump.rdb
Normal file
BIN
dump.rdb
Normal file
Binary file not shown.
5
spec/models/notfication_spec.rb
Normal file
5
spec/models/notfication_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
3
spec/models/notification.rb
Normal file
3
spec/models/notification.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
29
spec/models/notification_spec.rb
Normal file
29
spec/models/notification_spec.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
|
||||||
|
describe Notification do
|
||||||
|
before do
|
||||||
|
@sm = Factory(:status_message)
|
||||||
|
@person = Factory(:person)
|
||||||
|
@user = make_user
|
||||||
|
@note = Notification.new(:object_id => @sm.id, :kind => @sm.class.name, :person => @person, :user => @user)
|
||||||
|
puts @note.inspect
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'contains a type' do
|
||||||
|
@note.kind.should == StatusMessage.name
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'contains a object_id' do
|
||||||
|
@note.object_id.should == @sm.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'contains a person_id' do
|
||||||
|
@note.person.id == @person.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -58,14 +58,22 @@ describe User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'update posts' do
|
describe '#receive_object' do
|
||||||
|
it 'adds a notification for an object' do
|
||||||
|
Notification.should_receive(:new)
|
||||||
|
user = make_user
|
||||||
|
user.receive_object(Factory(:status_message), Factory(:person))
|
||||||
|
user.should_receive(:receive_post).and_return(true)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'update posts' do
|
||||||
it 'does not update posts not marked as mutable' do
|
it 'does not update posts not marked as mutable' do
|
||||||
status = user.post :status_message, :message => "store this!", :to => aspect.id
|
status = user.post :status_message, :message => "store this!", :to => aspect.id
|
||||||
status.message = 'foo'
|
status.message = 'foo'
|
||||||
xml = status.to_diaspora_xml
|
xml = status.to_diaspora_xml
|
||||||
user2.receive(xml, user.person)
|
user2.receive(xml, user.person)
|
||||||
|
|
||||||
status.reload.message.should == 'store this!'
|
status.reload.message.should == 'store this!'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -76,7 +84,6 @@ describe User do
|
||||||
user2.reload.receive(xml, user.person)
|
user2.reload.receive(xml, user.person)
|
||||||
photo.reload.caption.should match(/foo/)
|
photo.reload.caption.should match(/foo/)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'post refs' do
|
describe 'post refs' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue