aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations_test.rb
diff options
context:
space:
mode:
authorJosh Susser <josh@hasmanythrough.com>2011-11-15 23:30:25 -0800
committerJosh Susser <josh@hasmanythrough.com>2011-11-15 23:32:58 -0800
commit9cdf33af0bc46fde1ad50346b8271251c2b4aa69 (patch)
treeda67d8578f2723989c09e93045379078a806873f /activerecord/test/cases/associations_test.rb
parent7cba6a37848ba96b4decec885779fb309d71c339 (diff)
downloadrails-9cdf33af0bc46fde1ad50346b8271251c2b4aa69.tar.gz
rails-9cdf33af0bc46fde1ad50346b8271251c2b4aa69.tar.bz2
rails-9cdf33af0bc46fde1ad50346b8271251c2b4aa69.zip
add test for super-ing to association methods
Diffstat (limited to 'activerecord/test/cases/associations_test.rb')
-rw-r--r--activerecord/test/cases/associations_test.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index a9094b7a8b..0f75029215 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -276,7 +276,7 @@ class OverridingAssociationsTest < ActiveRecord::TestCase
end
class GeneratedMethodsTest < ActiveRecord::TestCase
- fixtures :developers, :computers
+ fixtures :developers, :computers, :posts, :comments
def test_association_methods_override_attribute_methods_of_same_name
assert_equal(developers(:david), computers(:workstation).developer)
# this next line will fail if the attribute methods module is generated lazily
@@ -284,4 +284,14 @@ class GeneratedMethodsTest < ActiveRecord::TestCase
assert_equal(developers(:david), computers(:workstation).developer)
assert_equal(developers(:david).id, computers(:workstation)[:developer])
end
-end \ No newline at end of file
+
+ 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