1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

don't change class definition in test case

This commit is contained in:
Josh Susser 2011-11-29 09:14:21 -08:00
parent 124c97fbe2
commit c347b3c06c
2 changed files with 4 additions and 6 deletions

View file

@ -286,12 +286,6 @@ class GeneratedMethodsTest < ActiveRecord::TestCase
end
def test_model_method_overrides_association_method
Post.class_eval <<-"RUBY"
has_one :first_comment, :class_name => 'Comment', :order => 'id ASC'
def first_comment
super.body
end
RUBY
assert_equal(comments(:greetings).body, posts(:welcome).first_comment)
end
end

View file

@ -24,6 +24,10 @@ class Post < ActiveRecord::Base
belongs_to :author_with_posts, :class_name => "Author", :foreign_key => :author_id, :include => :posts
belongs_to :author_with_address, :class_name => "Author", :foreign_key => :author_id, :include => :author_address
def first_comment
super.body
end
has_one :first_comment, :class_name => 'Comment', :order => 'id ASC'
has_one :last_comment, :class_name => 'Comment', :order => 'id desc'
scope :with_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'SpecialComment'} }