Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9640: test-sti.patch

File test-sti.patch, 1.8 kB (added by Aleksey Kondratenko, 4 months ago)

failing test for polymorphic association preloading on STI subclass

  • a/activerecord/test/associations/eager_test.rb

    old new  
    11require 'abstract_unit' 
    22require 'fixtures/post' 
     3require 'fixtures/tagging' 
    34require 'fixtures/comment' 
    45require 'fixtures/author' 
    56require 'fixtures/category' 
     
    910 
    1011class EagerAssociationTest < ActiveSupport::TestCase 
    1112  fixtures :posts, :comments, :authors, :categories, :categories_posts, 
    12             :companies, :accounts, :tags, :people, :readers 
     13            :companies, :accounts, :tags, :taggings, :people, :readers 
    1314 
    1415  def test_loading_with_one_association 
    1516    posts = Post.find(:all, :include => :comments) 
     
    363364  def test_preload_with_interpolation 
    364365    assert_equal [comments(:greetings)], Post.find(posts(:welcome).id, :include => :comments_with_interpolated_conditions).comments_with_interpolated_conditions 
    365366  end 
     367 
     368  def test_polymorphic_type_condition 
     369    post = Post.find(posts(:thinking).id, :include => :taggings) 
     370    assert post.taggings.include?(taggings(:thinking_general)) 
     371    post = SpecialPost.find(posts(:thinking).id, :include => :taggings) 
     372    assert post.taggings.include?(taggings(:thinking_general)) 
     373  end 
    366374   
    367375  def test_eager_with_multiple_associations_with_same_table_has_many_and_habtm 
    368376    # Eager includes of has many and habtm associations aren't necessarily sorted in the same way