From c347b3c06c2867badce5e22ecfbed3e972960c29 Mon Sep 17 00:00:00 2001
From: Josh Susser <josh@hasmanythrough.com>
Date: Tue, 29 Nov 2011 09:14:21 -0800
Subject: don't change class definition in test case

---
 activerecord/test/cases/associations_test.rb | 6 ------
 activerecord/test/models/post.rb             | 4 ++++
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index 0f75029215..efe71d1771 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -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
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 198a963cbc..137cee3752 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -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'} }
-- 
cgit v1.2.3