aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-12-08 19:58:59 +0000
committerJon Leighton <j@jonathanleighton.com>2011-12-08 20:10:04 +0000
commit5da90b34831a0f941b36edbede9089c54432ad6b (patch)
tree6296bb6f42860b55bc229d88e760de8c7655d9d6 /activerecord/test
parentebd71fd0e39abf495bdf64e3e6d278340c17e5ea (diff)
downloadrails-5da90b34831a0f941b36edbede9089c54432ad6b.tar.gz
rails-5da90b34831a0f941b36edbede9089c54432ad6b.tar.bz2
rails-5da90b34831a0f941b36edbede9089c54432ad6b.zip
Fix #3890. (Calling proxy_association in scope chain.)
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/extension_test.rb6
-rw-r--r--activerecord/test/models/post.rb6
2 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/extension_test.rb b/activerecord/test/cases/associations/extension_test.rb
index 8dc1423375..395b59258d 100644
--- a/activerecord/test/cases/associations/extension_test.rb
+++ b/activerecord/test/cases/associations/extension_test.rb
@@ -71,6 +71,12 @@ class AssociationsExtensionsTest < ActiveRecord::TestCase
assert_equal 'MyApplication::Business::DeveloperAssociationNameAssociationExtension', extension_name(MyApplication::Business::Developer)
end
+ def test_proxy_association_after_scoped
+ post = posts(:welcome)
+ assert_equal post.association(:comments), post.comments.the_association
+ assert_equal post.association(:comments), post.comments.scoped.the_association
+ end
+
private
def extension_name(model)
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 137cee3752..1cab78d8c7 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -44,6 +44,10 @@ class Post < ActiveRecord::Base
def newest
created.last
end
+
+ def the_association
+ proxy_association
+ end
end
has_many :author_favorites, :through => :author
@@ -185,4 +189,4 @@ end
class SpecialPostWithDefaultScope < ActiveRecord::Base
self.table_name = 'posts'
default_scope where(:id => [1, 5,6])
-end \ No newline at end of file
+end