diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-02 16:11:29 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-02 16:11:29 -0700 |
commit | 79b88e875b407f8418932fb757999909c2083b89 (patch) | |
tree | db0195ee27c7abfdce70b027d69e5aa875b19e97 /activerecord/test/cases | |
parent | 1a5394f4afdf2eeadd91b5b0ff5ad199c9dc93b0 (diff) | |
download | rails-79b88e875b407f8418932fb757999909c2083b89.tar.gz rails-79b88e875b407f8418932fb757999909c2083b89.tar.bz2 rails-79b88e875b407f8418932fb757999909c2083b89.zip |
fix to_sql output on eager loaded relations
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 7a6d9be515..b205472cf5 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -481,6 +481,14 @@ class RelationTest < ActiveRecord::TestCase assert_equal Post.find(1).last_comment, post.last_comment end + def test_to_sql_on_eager_join + expected = assert_sql { + Post.eager_load(:last_comment).order('comments.id DESC').to_a + }.first + actual = Post.eager_load(:last_comment).order('comments.id DESC').to_sql + assert_equal expected, actual + end + def test_loading_with_one_association_with_non_preload posts = Post.eager_load(:last_comment).order('comments.id DESC') post = posts.find { |p| p.id == 1 } |