diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-10-12 09:41:00 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-10-12 09:41:00 -0700 |
commit | 1cb7cb04eb78bc5a2b0f4c79215f2a38bbfa5a5e (patch) | |
tree | f100600013a2c55b63baa853ff79992ad3734797 /activerecord/test/cases/relations_test.rb | |
parent | 79db8db415ffb86ab23e4d319c1035d926160d2d (diff) | |
parent | 633ea6a826cb5e587165f78d15770271cb39f670 (diff) | |
download | rails-1cb7cb04eb78bc5a2b0f4c79215f2a38bbfa5a5e.tar.gz rails-1cb7cb04eb78bc5a2b0f4c79215f2a38bbfa5a5e.tar.bz2 rails-1cb7cb04eb78bc5a2b0f4c79215f2a38bbfa5a5e.zip |
Merge pull request #7765 from insside/clever-order
learn ActiveReccord::Querying#order work with hash arguments
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index d801770118..fdbc0a3fdb 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -157,6 +157,22 @@ class RelationTest < ActiveRecord::TestCase assert_equal 4, topics.to_a.size assert_equal topics(:first).title, topics.first.title end + + def test_finding_with_assoc_order + topics = Topic.order(:id => :desc) + assert_equal 4, topics.to_a.size + assert_equal topics(:fourth).title, topics.first.title + end + + def test_finding_with_reverted_assoc_order + topics = Topic.order(:id => :asc).reverse_order + assert_equal 4, topics.to_a.size + assert_equal topics(:fourth).title, topics.first.title + end + + def test_raising_exception_on_invalid_hash_params + assert_raise(ArgumentError) { Topic.order(:name, "id DESC", :id => :DeSc) } + end def test_finding_last_with_arel_order topics = Topic.order(Topic.arel_table[:id].asc) |