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

Ticket #8267: test_multiple_table_references_on_cascaded_eager_loading.diff

File test_multiple_table_references_on_cascaded_eager_loading.diff, 2.9 kB (added by mattwestcott, 2 years ago)

currently-failing test case

  • activerecord/test/associations/join_model_test.rb

    old new  
    483483  def test_has_many_through_has_many_with_sti 
    484484    assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments 
    485485  end 
     486   
     487  def test_multiple_table_references_on_cascaded_eager_loading 
     488    assert_equal comments(:greetings), authors(:david).comments_with_cited_posts.find(:all, :order => 'comments.id').first 
     489  end 
    486490 
    487491  private 
    488492    # create dynamic Post models to allow different dependency options 
  • activerecord/test/fixtures/comment.rb

    old new  
    11class Comment < ActiveRecord::Base 
    22  belongs_to :post 
     3  has_many :post_citations 
    34   
    45  def self.what_are_you 
    56    'a comment...' 
     
    2021  def self.what_are_you 
    2122    'a very special comment...' 
    2223  end 
     24end 
     25 
     26class PostCitation < ActiveRecord::Base 
     27  belongs_to :comment 
     28  belongs_to :post 
    2329end 
  • activerecord/test/fixtures/db_definitions/schema.rb

    old new  
    3939    t.column :author_id, :integer 
    4040    t.column :favorite_author_id, :integer 
    4141  end 
     42   
     43  create_table :post_citations, :force => true do |t| 
     44    t.column :comment_id, :integer 
     45    t.column :post_id, :integer 
     46  end 
    4247 
    4348  create_table :vertices, :force => true do |t| 
    4449    t.column :label, :string 
  • activerecord/test/fixtures/post.rb

    old new  
    1212      find(:first, :order => "id DESC") 
    1313    end 
    1414  end 
     15   
     16  has_many :comments_with_cited_posts, :class_name => "Comment", :include => {:post_citations => :post} 
    1517 
    1618  has_one  :very_special_comment 
    1719  has_one  :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post 
  • activerecord/test/fixtures/author.rb

    old new  
    1616  end 
    1717  has_many :comments, :through => :posts 
    1818  has_many :funky_comments, :through => :posts, :source => :comments 
     19  has_many :comments_with_cited_posts, :through => :posts 
    1920 
    2021  has_many :special_posts 
    2122  has_many :special_post_comments, :through => :special_posts, :source => :comments