aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMiguel Grazziotin <miguelgraz@gmail.com>2015-06-03 21:09:34 -0300
committerMiguel Grazziotin <miguelgraz@gmail.com>2015-06-03 21:09:34 -0300
commit91276036ecf2745a44399b11a9779b8bec7c7fbb (patch)
tree4e3fa5808b7351b0b862d7cfcb13fab7a94655d9 /activerecord/test
parent24389135b2eac027f3079476e776587c5f74b350 (diff)
downloadrails-91276036ecf2745a44399b11a9779b8bec7c7fbb.tar.gz
rails-91276036ecf2745a44399b11a9779b8bec7c7fbb.tar.bz2
rails-91276036ecf2745a44399b11a9779b8bec7c7fbb.zip
[#20338] adding tests to ensure the order clause takes precedence
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/finder_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index f9d75fc937..445b20ca2a 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -58,6 +58,24 @@ class FinderTest < ActiveRecord::TestCase
assert_equal 'The Fourth Topic of the day', records[0].title
assert_equal 'The Second Topic of the day', records[1].title
assert_equal 'The Fifth Topic of the day', records[2].title
+
+ records = Topic.find(['4','2','5'])
+ assert_equal 'The Fourth Topic of the day', records[0].title
+ assert_equal 'The Second Topic of the day', records[1].title
+ assert_equal 'The Fifth Topic of the day', records[2].title
+
+ records = Topic.find('4','2','5')
+ assert_equal 'The Fourth Topic of the day', records[0].title
+ assert_equal 'The Second Topic of the day', records[1].title
+ assert_equal 'The Fifth Topic of the day', records[2].title
+ end
+
+ def test_find_with_ids_and_order_clause
+ # The order clause takes precedence over the informed ids
+ records = Topic.order(:author_name).find([5,3,1])
+ assert_equal 'The Third Topic of the day', records[0].title
+ assert_equal 'The First Topic', records[1].title
+ assert_equal 'The Fifth Topic of the day', records[2].title
end
def test_find_passing_active_record_object_is_deprecated