remove object_id for notifications thx sarahmei for pointing out my evil ways
This commit is contained in:
parent
ed0e739ac3
commit
e0883fb176
3 changed files with 7 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ module NotificationsHelper
|
||||||
when 'new_request'
|
when 'new_request'
|
||||||
translation
|
translation
|
||||||
when 'comment_on_post'
|
when 'comment_on_post'
|
||||||
"#{translation} #{link_to t('notifications.post'), object_path(Comment.first(:id => note.object_id).post)}".html_safe
|
"#{translation} #{link_to t('notifications.post'), object_path(Comment.first(:id => note.target_id).post)}".html_safe
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
class Notification
|
class Notification
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
|
|
||||||
key :object_id, ObjectId
|
key :target_id, ObjectId
|
||||||
key :kind, String
|
key :kind, String
|
||||||
key :unread, Boolean, :default => true
|
key :unread, Boolean, :default => true
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Notification
|
||||||
|
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
||||||
attr_accessible :object_id, :kind, :user_id, :person_id, :unread
|
attr_accessible :target_id, :kind, :user_id, :person_id, :unread
|
||||||
|
|
||||||
def self.for(user, opts={})
|
def self.for(user, opts={})
|
||||||
self.where(opts.merge!(:user_id => user.id)).order('created_at desc')
|
self.where(opts.merge!(:user_id => user.id)).order('created_at desc')
|
||||||
|
|
@ -23,7 +23,7 @@ class Notification
|
||||||
def self.notify(user, object, person)
|
def self.notify(user, object, person)
|
||||||
if object.respond_to? :notification_type
|
if object.respond_to? :notification_type
|
||||||
if kind = object.notification_type(user, person)
|
if kind = object.notification_type(user, person)
|
||||||
Notification.create(:object_id => object.id,
|
Notification.create(:target_id => object.id,
|
||||||
:kind => kind,
|
:kind => kind,
|
||||||
:person_id => person.id,
|
:person_id => person.id,
|
||||||
:user_id => user.id)
|
:user_id => user.id)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ describe Notification do
|
||||||
@user = make_user
|
@user = make_user
|
||||||
@user2 = make_user
|
@user2 = make_user
|
||||||
@aspect = @user.aspects.create(:name => "dudes")
|
@aspect = @user.aspects.create(:name => "dudes")
|
||||||
@opts = {:object_id => @sm.id, :kind => @sm.class.name, :person_id => @person.id, :user_id => @user.id}
|
@opts = {:target_id => @sm.id, :kind => @sm.class.name, :person_id => @person.id, :user_id => @user.id}
|
||||||
@note = Notification.new(@opts)
|
@note = Notification.new(@opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -20,8 +20,8 @@ describe Notification do
|
||||||
@note.kind.should == StatusMessage.name
|
@note.kind.should == StatusMessage.name
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains a object_id' do
|
it 'contains a target_id' do
|
||||||
@note.object_id.should == @sm.id
|
@note.target_id.should == @sm.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains a person_id' do
|
it 'contains a person_id' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue