Sha256: 48639b261238aaaf13e5fc32c5f7db7de0f176053965292618f8f89ca6053516

Contents?: true

Size: 735 Bytes

Versions: 7

Compression:

Stored size: 735 Bytes

Contents

class Comment < ActiveRecord::Base
  # see spec/examples folder for typically setup
  belongs_to :author, class_name: "User"
  belongs_to :todoz, class_name: "Todo", foreign_key: :todo_id
end

class Comment < ActiveRecord::Base

  def create_permitted?
    # for testing we allow anything if there is no acting_user
    # in the real world you would have something like this:
    # acting_user and (acting_user.admin? or user_is? acting_user)
    !acting_user or user_is? acting_user
  end

  def destroy_permitted?
    !acting_user or user_is? acting_user
  end

  belongs_to :user
  belongs_to :todo_item

  has_one :todo, -> {}, class_name: "TodoItem"  # this is just so we can test scopes params and null belongs_to relations

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyper-mesh-0.6.0 spec/test_app/app/models/public/comment.rb
hyper-mesh-0.5.4 spec/test_app/app/models/public/comment.rb
hyper-mesh-0.5.3 spec/test_app/app/models/public/comment.rb
hyper-mesh-0.5.2 spec/test_app/app/models/public/comment.rb
hyper-mesh-0.5.1 spec/test_app/app/models/public/comment.rb
hyper-mesh-0.5.0 spec/test_app/app/models/public/comment.rb
hyper-mesh-0.4.0 spec/test_app/app/models/public/comment.rb