diff --git a/app/models/notification.rb b/app/models/notification.rb new file mode 100644 index 000000000..dd71884e5 --- /dev/null +++ b/app/models/notification.rb @@ -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 diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 000000000..04bb32a05 Binary files /dev/null and b/dump.rdb differ diff --git a/spec/models/notfication_spec.rb b/spec/models/notfication_spec.rb new file mode 100644 index 000000000..f2f6d240f --- /dev/null +++ b/spec/models/notfication_spec.rb @@ -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' diff --git a/spec/models/notification.rb b/spec/models/notification.rb new file mode 100644 index 000000000..b0ae52638 --- /dev/null +++ b/spec/models/notification.rb @@ -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. diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb new file mode 100644 index 000000000..d74333965 --- /dev/null +++ b/spec/models/notification_spec.rb @@ -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 + diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index b76c3b28f..50b7dba70 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -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