Sha256: 0f5f90ba9d8bb122a26814fb71523992e10192534d7b14512cc464384d801cce
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require File.dirname(__FILE__) + '/joinfix_test_helper' # # hm as # class HasManyAsMigration < ActiveRecord::Migration def self.up create_table :hm_as_parents do |t| t.column :field, :string end create_table :hm_as_children do |t| t.column :polymorphic_parent_id, :integer t.column :polymorphic_parent_type, :string t.column :field, :string end end def self.down drop_table :hm_as_parents drop_table :hm_as_children end end class HmAsParent < ActiveRecord::Base has_many :hm_as_children, :as => :polymorphic_parent end class HmAsChild < ActiveRecord::Base belongs_to :polymorphic_parent, :polymorphic => true end class HasManyAsTest < Test::Unit::TestCase fixtures :hm_as_parents, :hm_as_children def test_has_many_as setup_fixtures( :hm_as_parents => %Q{ parent_entry: field: parent value hm_as_children: child_one: field: one child_two: field: two}, :hm_as_children => "") assert_fixtures( :hm_as_parents => %Q{ parent_entry: id: 1 field: parent value}, :hm_as_children => %Q{ child_one: id: 1 polymorphic_parent_id: 1 polymorphic_parent_type: HmAsParent field: one child_two: id: 2 polymorphic_parent_id: 1 polymorphic_parent_type: HmAsParent field: two}) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
joinfix-0.1.1 | test/has_many_as_test.rb |
joinfix-1.0.0 | test/has_many_as_test.rb |
joinfix-1.0.1 | test/has_many_as_test.rb |