aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMarcelo Silveira <marcelo@mhfs.com.br>2012-04-26 19:27:55 -0300
committerMarcelo Silveira <marcelo@mhfs.com.br>2012-05-02 21:25:24 -0300
commit07e5301e697d6a02ed3c079aba07c261d53c1846 (patch)
tree10673ccc1c8d33e3733c9a35332c5082780daeb2 /activerecord/test/cases
parent56030506563352944fed12a6bb4793bb2462094b (diff)
downloadrails-07e5301e697d6a02ed3c079aba07c261d53c1846.tar.gz
rails-07e5301e697d6a02ed3c079aba07c261d53c1846.tar.bz2
rails-07e5301e697d6a02ed3c079aba07c261d53c1846.zip
Made `first` finder consistent among database engines by adding a
default order clause (fixes #5103)
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/finder_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 29469c42ed..fdc7fad40a 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -163,6 +163,12 @@ class FinderTest < ActiveRecord::TestCase
end
end
+ def test_first_have_primary_key_order_by_default
+ expected = topics(:first)
+ expected.touch # PostgreSQL changes the default order if no order clause is used
+ assert_equal expected, Topic.first
+ end
+
def test_model_class_responds_to_first_bang
assert Topic.first!
Topic.delete_all