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

Ticket #11545: named_scopes_with_finder_sql_failing_test.diff

File named_scopes_with_finder_sql_failing_test.diff, 1.4 kB (added by Henrik N, 6 months ago)
  • rails/activerecord/test/models/author.rb

    old new  
    11class Author < ActiveRecord::Base 
    22  has_many :posts 
     3  has_many :posts_with_finder_sql, :class_name => "Post", :finder_sql => 'SELECT * FROM posts WHERE author_id = #{id}' 
    34  has_many :posts_with_comments, :include => :comments, :class_name => "Post" 
    45  has_many :posts_with_categories, :include => :categories, :class_name => "Post" 
    56  has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post" 
  • rails/activerecord/test/cases/named_scope_test.rb

    old new  
    112112 
    113113    assert_equal Topic.find(:all, scope), Topic.scoped(scope) 
    114114  end 
     115   
     116  def test_finder_sql 
     117    # Sanity check 
     118    assert_equal authors(:david).posts, authors(:david).posts_with_finder_sql 
     119    # Currently fails: the latter returns nil 
     120    assert_equal authors(:david).posts.containing_the_letter_a, 
     121                 authors(:david).posts_with_finder_sql.containing_the_letter_a 
     122  end 
     123   
    115124end