adding basic notification class

This commit is contained in:
maxwell 2010-12-15 12:11:37 -08:00
parent bd31ff3ee3
commit a7d36615e6
6 changed files with 65 additions and 3 deletions

View 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

Binary file not shown.

View 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'

View 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.

View 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

View file

@ -58,14 +58,22 @@ describe User do
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
status = user.post :status_message, :message => "store this!", :to => aspect.id
status.message = 'foo'
xml = status.to_diaspora_xml
user2.receive(xml, user.person)
status.reload.message.should == 'store this!'
end
@ -76,7 +84,6 @@ describe User do
user2.reload.receive(xml, user.person)
photo.reload.caption.should match(/foo/)
end
end
describe 'post refs' do