DG IZ; posting from a user includes adding to the many posts association in said user

This commit is contained in:
ilya 2010-08-17 10:43:18 -07:00
parent 5761d5db36
commit a9c9619a54
2 changed files with 11 additions and 1 deletions

View file

@ -44,7 +44,11 @@ class User
post = model_class.instantiate(options)
post.creator_signature = post.sign_with_key(encryption_key)
post.notify_people
post.socket_to_uid owner.id if (owner_id && post.respond_to?( :socket_to_uid))
post.socket_to_uid owner.id if (owner_id && post.respond_to?(:socket_to_uid))
self.posts << post
self.save
post
end ######### Posts and Such ###############

View file

@ -283,6 +283,12 @@ describe User do
@user.posts.count.should == 0
end
it "should add the post to that user's posts when a user posts it" do
status_message = @user.post :status_message, :message => "hi"
@user.reload
@user.posts.include?(status_message).should be true
end
it 'should be removed on unfriending' do
status_message = @user2.post :status_message, :message => "hi"