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:
parent
124c97fbe2
commit
c347b3c06c
2 changed files with 4 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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'} }
|
||||
|
|
Loading…
Reference in a new issue