Sha256: f5449e42b41d5e48a501fbd4959dc0ef89cfef6b6e84bee232353deed9798064

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'mr'
require 'mr/fake_record'
require 'test/support/models/user'

class CommentRecord < ActiveRecord::Base
  include MR::Record
  self.table_name = 'comments'

  belongs_to :parent, {
    :polymorphic => true
  }
  belongs_to :created_by, {
    :class_name  => 'UserRecord',
    :foreign_key => 'created_by_id'
  }

  belongs_to :benchmark_parent, {
    :polymorphic => true
  }

end

class Comment
  include MR::Model
  record_class CommentRecord

  field_reader :id, :parent_id
  field_accessor :body, :parent_type, :created_at

  polymorphic_belongs_to :parent
  belongs_to :created_by

  polymorphic_belongs_to :benchmark_parent

end

class FakeCommentRecord
  include MR::FakeRecord
  model_class Comment

  attribute :body,          :text
  attribute :parent_type,   :string,   :null => false
  attribute :parent_id,     :integer,  :null => false
  attribute :created_at,    :datetime
  attribute :created_by_id, :integer

  belongs_to :parent, {
    :polymorphic => true
  }
  belongs_to :created_by, {
    :class_name  => 'FakeUserRecord',
    :foreign_key => 'created_by_id'
  }

  belongs_to :benchmark_parent, {
    :polymorphic => true
  }

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mr-0.35.2 test/support/models/comment.rb