diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-08-29 15:01:17 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-08-29 15:05:47 +0100 |
commit | 735d985b0162976e7e900cf36d4cbb0d657fb5e9 (patch) | |
tree | 6d28ea963504b2f458b81eb6c32ac471b937f316 /activerecord/test | |
parent | fd22d040fef48778a519825dd2f0cf2fd73a8965 (diff) | |
download | rails-735d985b0162976e7e900cf36d4cbb0d657fb5e9.tar.gz rails-735d985b0162976e7e900cf36d4cbb0d657fb5e9.tar.bz2 rails-735d985b0162976e7e900cf36d4cbb0d657fb5e9.zip |
The join_nodes must be passed to the JoinDependency initializer and therefore counted by the alias tracker. This is because the association_joins are aliased on initialization and then the tables are cached, so it is no use to alias the join_nodes later. Fixes #2556.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/toy.rb | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 5f2328ff95..b703c96ec1 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -821,4 +821,8 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert person.posts.loaded?, 'person.posts should be loaded' assert_equal [], person.posts end + + def test_explicitly_joining_join_table + assert_equal owners(:blackbeard).toys, owners(:blackbeard).toys.with_pet + end end diff --git a/activerecord/test/models/toy.rb b/activerecord/test/models/toy.rb index 79a88db0da..6c45e99671 100644 --- a/activerecord/test/models/toy.rb +++ b/activerecord/test/models/toy.rb @@ -1,4 +1,6 @@ class Toy < ActiveRecord::Base set_primary_key :toy_id belongs_to :pet + + scope :with_pet, joins(:pet) end |