diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-06-28 14:55:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-06-28 14:55:15 -0700 |
commit | 59e38803e90a25adcaefdc051c5abcb170c33672 (patch) | |
tree | 8f0dbbb57360cce00b8fffb66513f2bfa7ee9e2e /activerecord/test | |
parent | 931cf17c336ba7db01c440ea7c177b564d423e52 (diff) | |
parent | 56ac32ad51b0c46bc3034b7cf0d7ff58e24bbbd5 (diff) | |
download | rails-59e38803e90a25adcaefdc051c5abcb170c33672.tar.gz rails-59e38803e90a25adcaefdc051c5abcb170c33672.tar.bz2 rails-59e38803e90a25adcaefdc051c5abcb170c33672.zip |
Merge pull request #1574 from oriolgual/1571_ar_relation_order_no_longer_works_with_arel_nodes
Fix #1571 ActiveRecord::Relation#order no longer works with arel ordering nodes
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation_scoping_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb index 77b7648576..f2d177d834 100644 --- a/activerecord/test/cases/relation_scoping_test.rb +++ b/activerecord/test/cases/relation_scoping_test.rb @@ -15,6 +15,18 @@ class RelationScopingTest < ActiveRecord::TestCase assert_equal Developer.order("id DESC").to_a.reverse, Developer.order("id DESC").reverse_order end + def test_reverse_order_with_arel_node + assert_equal Developer.order("id DESC").to_a.reverse, Developer.order(Developer.arel_table[:id].desc).reverse_order + end + + def test_reverse_order_with_multiple_arel_nodes + assert_equal Developer.order("id DESC").order("name DESC").to_a.reverse, Developer.order(Developer.arel_table[:id].desc).order(Developer.arel_table[:name].desc).reverse_order + end + + def test_reverse_order_with_arel_nodes_and_strings + assert_equal Developer.order("id DESC").order("name DESC").to_a.reverse, Developer.order("id DESC").order(Developer.arel_table[:name].desc).reverse_order + end + def test_double_reverse_order_produces_original_order assert_equal Developer.order("name DESC"), Developer.order("name DESC").reverse_order.reverse_order end |