aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorTima Maslyuchenko <n3imo0o@gmail.com>2012-09-26 22:16:17 +0300
committerTima Maslyuchenko <n3imo0o@gmail.com>2012-10-12 17:57:24 +0300
commit633ea6a826cb5e587165f78d15770271cb39f670 (patch)
treef100600013a2c55b63baa853ff79992ad3734797 /activerecord/test/cases/relations_test.rb
parent79db8db415ffb86ab23e4d319c1035d926160d2d (diff)
downloadrails-633ea6a826cb5e587165f78d15770271cb39f670.tar.gz
rails-633ea6a826cb5e587165f78d15770271cb39f670.tar.bz2
rails-633ea6a826cb5e587165f78d15770271cb39f670.zip
learn ActiveRecord::QueryMethods#order work with hash arguments
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb16
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)