aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2013-04-03 23:39:09 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2013-04-04 15:45:13 -0400
commit812469943cc6eddc132d137a0d5929b2c5d0346f (patch)
tree07e3cdbb65d8c2440a877d8e45c49e721607c66f /activerecord/test/cases/associations/has_many_through_associations_test.rb
parentdb113d90caabf7a5d16aef4b61d41155eb5b86c6 (diff)
downloadrails-812469943cc6eddc132d137a0d5929b2c5d0346f.tar.gz
rails-812469943cc6eddc132d137a0d5929b2c5d0346f.tar.bz2
rails-812469943cc6eddc132d137a0d5929b2c5d0346f.zip
has_many through obeys order on through association
fixes #10016
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb8
1 files changed, 7 insertions, 1 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 67d18f313a..70c6b489aa 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -583,7 +583,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
def test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
- assert_equal 1, owners(:blackbeard).toys.count
+ assert_equal 2, owners(:blackbeard).toys.count
end
def test_find_on_has_many_association_collection_with_include_and_conditions
@@ -882,6 +882,12 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert_equal [tags(:general)], post.reload.tags
end
+ def test_has_many_through_obeys_order_on_through_association
+ owner = owners(:blackbeard)
+ assert owner.toys.to_sql.include?("pets.name desc")
+ assert_equal ["parrot", "bulbul"], owner.toys.map { |r| r.pet.name }
+ end
+
test "has many through associations on new records use null relations" do
person = Person.new