Sha256: 1c094ee8c9bde6174c320d2c6738e189518fbe8cdf90f1afc516d4d6b65ea574
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
require File.dirname(__FILE__) + '/joinfix_test_helper' # # polymorphic # class BelongsToPolymorphicMigration < ActiveRecord::Migration def self.up create_table :bt_polymorphics do |t| t.column :field, :string t.column :polymorph_id, :integer t.column :polymorph_type, :string end create_table :bt_children do |t| t.column :field, :string end create_table :polymorphic_children do |t| t.column :field, :string end end def self.down drop_table :bt_polymorphics drop_table :bt_children drop_table :polymorphic_children end end class BtPolymorphic < ActiveRecord::Base belongs_to :polymorph, :polymorphic => true end class PolymorphicChild < ActiveRecord::Base has_many :bt_parents, :as => :polymorph end class BelongsToPolymorphicTest < Test::Unit::TestCase fixtures :bt_polymorphics, :polymorphic_children def test_belongs_to_polymorphic setup_fixtures( :bt_polymorphics => %Q{ parent_entry: field: parent value polymorph_type: PolymorphicChild polymorph: child_entry: field: child value}, :polymorphic_children => "") assert_fixtures( :bt_polymorphics => %Q{ parent_entry: id: 1 polymorph_id: 1 polymorph_type: PolymorphicChild field: parent value}, :polymorphic_children => %Q{ child_entry: id: 1 field: child value}) end def test_error_if_polymorphic_type_is_mising error_test(MissingPolymorphicTypeError) do setup_fixtures( :bt_polymorphics => %Q{ parent_entry: field: parent value polymorph: child_entry: field: child value}, :polymorphic_children => "") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
joinfix-0.1.1 | test/belongs_to_polymorphic_test.rb |
joinfix-1.0.0 | test/belongs_to_polymorphic_test.rb |
joinfix-1.0.1 | test/belongs_to_polymorphic_test.rb |