From c95f066bf5b5121ff86db090eff3436e63db9230 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Tue, 20 Nov 2007 21:53:22 +0000 Subject: Add 'foxy' support for fixtures of polymorphic associations. Closes #10183 [jbarnette, David Lowenfels] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8170 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/fixtures/db_definitions/schema.rb | 2 ++ activerecord/test/fixtures/parrot.rb | 1 + activerecord/test/fixtures/pirate.rb | 1 + activerecord/test/fixtures/treasure.rb | 1 + activerecord/test/fixtures/treasures.yml | 2 ++ 5 files changed, 7 insertions(+) (limited to 'activerecord/test/fixtures') diff --git a/activerecord/test/fixtures/db_definitions/schema.rb b/activerecord/test/fixtures/db_definitions/schema.rb index 5bde5126d5..12dbcb8423 100644 --- a/activerecord/test/fixtures/db_definitions/schema.rb +++ b/activerecord/test/fixtures/db_definitions/schema.rb @@ -327,6 +327,8 @@ ActiveRecord::Schema.define do create_table :treasures, :force => true do |t| t.column :name, :string + t.column :looter_id, :integer + t.column :looter_type, :string end create_table :parrots_treasures, :id => false, :force => true do |t| diff --git a/activerecord/test/fixtures/parrot.rb b/activerecord/test/fixtures/parrot.rb index 340c73b907..10850669e7 100644 --- a/activerecord/test/fixtures/parrot.rb +++ b/activerecord/test/fixtures/parrot.rb @@ -1,4 +1,5 @@ class Parrot < ActiveRecord::Base has_and_belongs_to_many :pirates has_and_belongs_to_many :treasures + has_many :loots, :as => :looter end diff --git a/activerecord/test/fixtures/pirate.rb b/activerecord/test/fixtures/pirate.rb index d22d66bac9..f7193dfbe0 100644 --- a/activerecord/test/fixtures/pirate.rb +++ b/activerecord/test/fixtures/pirate.rb @@ -1,4 +1,5 @@ class Pirate < ActiveRecord::Base belongs_to :parrot has_and_belongs_to_many :parrots + has_many :loots, :as => :looter end diff --git a/activerecord/test/fixtures/treasure.rb b/activerecord/test/fixtures/treasure.rb index cbb3ec3c08..7a429e2a2f 100644 --- a/activerecord/test/fixtures/treasure.rb +++ b/activerecord/test/fixtures/treasure.rb @@ -1,3 +1,4 @@ class Treasure < ActiveRecord::Base has_and_belongs_to_many :parrots + belongs_to :looter, :polymorphic => true end diff --git a/activerecord/test/fixtures/treasures.yml b/activerecord/test/fixtures/treasures.yml index c6fe30d0e3..9db15798fd 100644 --- a/activerecord/test/fixtures/treasures.yml +++ b/activerecord/test/fixtures/treasures.yml @@ -3,6 +3,8 @@ diamond: sapphire: name: $LABEL + looter: redbeard (Pirate) ruby: name: $LABEL + looter: louis (Parrot) -- cgit v1.2.3