aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-23 15:58:34 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-23 15:58:34 -0700
commite5299c1ef693ef434f55811027a7da975cd55ba5 (patch)
tree24b28fc1f661c7cb41107416dabeb7c65e84d1fb /activerecord/test/cases
parent6f9ea581da9381d4ce4422fe1dad1f55ee6f862a (diff)
downloadrails-e5299c1ef693ef434f55811027a7da975cd55ba5.tar.gz
rails-e5299c1ef693ef434f55811027a7da975cd55ba5.tar.bz2
rails-e5299c1ef693ef434f55811027a7da975cd55ba5.zip
hm:t preloading will respect order set on the RHS association
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb15
1 files changed, 15 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 dd8b426b25..99c71a1dd9 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -41,6 +41,21 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
Class.new(ActiveRecord::Base) { define_singleton_method(:name) { name } }
end
+ def test_ordered_habtm
+ person_prime = Class.new(ActiveRecord::Base) do
+ def self.name; 'Person'; end
+
+ has_many :readers
+ has_many :posts, -> { order('posts.id DESC') }, :through => :readers
+ end
+ posts = person_prime.includes(:posts).first.posts
+
+ assert_operator posts.length, :>, 1
+ posts.each_cons(2) do |left,right|
+ assert_operator left.id, :>, right.id
+ end
+ end
+
def test_singleton_has_many_through
book = make_model "Book"
subscription = make_model "Subscription"