diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations/join_model_test.rb | 13 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/schema.rb | 4 | ||||
-rw-r--r-- | activerecord/test/fixtures/item.rb | 7 | ||||
-rw-r--r-- | activerecord/test/fixtures/items.yml | 4 | ||||
-rw-r--r-- | activerecord/test/fixtures/taggings.yml | 9 |
5 files changed, 34 insertions, 3 deletions
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb index 84078e6fff..2e1b4dae88 100644 --- a/activerecord/test/associations/join_model_test.rb +++ b/activerecord/test/associations/join_model_test.rb @@ -2,6 +2,7 @@ require 'abstract_unit' require 'fixtures/tag' require 'fixtures/tagging' require 'fixtures/post' +require 'fixtures/item' require 'fixtures/comment' require 'fixtures/author' require 'fixtures/category' @@ -11,7 +12,7 @@ require 'fixtures/edge' class AssociationsJoinModelTest < Test::Unit::TestCase self.use_transactional_fixtures = false - fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices + fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items def test_has_many assert authors(:david).categories.include?(categories(:general)) @@ -229,7 +230,15 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_equal tagging, post.tagging end end - + + def test_include_polymorphic_has_one_defined_in_abstract_parent + item = Item.find_by_id(items(:dvd).id, :include => :tagging) + tagging = taggings(:godfather) + assert_no_queries do + assert_equal tagging, item.tagging + end + end + def test_include_polymorphic_has_many_through posts = Post.find(:all, :order => 'posts.id') posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id') diff --git a/activerecord/test/fixtures/db_definitions/schema.rb b/activerecord/test/fixtures/db_definitions/schema.rb index 3dc9a9b8a3..cdebcbbe5f 100644 --- a/activerecord/test/fixtures/db_definitions/schema.rb +++ b/activerecord/test/fixtures/db_definitions/schema.rb @@ -57,6 +57,10 @@ ActiveRecord::Schema.define do create_table :lock_without_defaults_cust, :force => true do |t| t.column :custom_lock_version, :integer end + + create_table :items, :force => true do |t| + t.column :name, :integer + end # For sqlite 3.1.0+, make a table with a autoincrement column if adapter_name == 'SQLite' and supports_autoincrement? diff --git a/activerecord/test/fixtures/item.rb b/activerecord/test/fixtures/item.rb new file mode 100644 index 0000000000..c2571dd7fb --- /dev/null +++ b/activerecord/test/fixtures/item.rb @@ -0,0 +1,7 @@ +class AbstractItem < ActiveRecord::Base + self.abstract_class = true + has_one :tagging, :as => :taggable +end + +class Item < AbstractItem +end diff --git a/activerecord/test/fixtures/items.yml b/activerecord/test/fixtures/items.yml new file mode 100644 index 0000000000..31fd657df9 --- /dev/null +++ b/activerecord/test/fixtures/items.yml @@ -0,0 +1,4 @@ +dvd: + id: 1 + name: Godfather +
\ No newline at end of file diff --git a/activerecord/test/fixtures/taggings.yml b/activerecord/test/fixtures/taggings.yml index 617210d604..2213b15494 100644 --- a/activerecord/test/fixtures/taggings.yml +++ b/activerecord/test/fixtures/taggings.yml @@ -15,4 +15,11 @@ fake: id: 3 tag_id: 1 taggable_id: 1 - taggable_type: FakeModel
\ No newline at end of file + taggable_type: FakeModel + +godfather: + id: 4 + tag_id: 1 + taggable_id: 1 + taggable_type: Item +
\ No newline at end of file |