Skip to content
This repository has been archived by the owner on Jan 30, 2018. It is now read-only.

Commit

Permalink
comments with uploads: copy project_id from comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jun 16, 2010
1 parent 122cf74 commit 82e2e7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/upload.rb
Expand Up @@ -10,7 +10,7 @@ class Upload < RoleRecord
has_one :page_slot, :as => :rel_object
before_destroy :clear_slot

before_create :copy_user_id_from_comment
before_create :copy_ownership_from_comment

default_scope :order => 'created_at DESC'

Expand Down Expand Up @@ -101,9 +101,10 @@ def to_xml(options = {})

protected

def copy_user_id_from_comment
def copy_ownership_from_comment
if comment_id
self.user_id = comment.user_id
self.project_id = comment.project_id
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/models/comment_spec.rb
Expand Up @@ -334,6 +334,7 @@
upload.comment.should == comment
upload.description.should == 'Here is that dog video I promised'
upload.user_id.should == comment.user_id
upload.project_id.should == comment.project_id
end
end
end

0 comments on commit 82e2e7f

Please sign in to comment.