From 0df27c98d982ec87d2fb48cfda82694eb267993e Mon Sep 17 00:00:00 2001 From: Joshua Wehner Date: Wed, 31 Aug 2011 15:04:41 -0400 Subject: Fixes bug in ActiveRecord::QueryMethods, #1697 Replace split on comma with a regexp that will reverse all ASC/DESC specifically --- activerecord/test/cases/relations_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test/cases/relations_test.rb') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index da96afd718..c3bad58174 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -934,6 +934,11 @@ class RelationTest < ActiveRecord::TestCase assert_equal 'zyke', FastCar.order_using_old_style.limit(1).first.name end + def test_order_with_function_and_last + authors = Author.scoped + assert_equal authors(:bob), authors.order( "id asc, COALESCE( organization_id, owned_essay_id)" ).last + end + def test_order_using_scoping car1 = CoolCar.order('id DESC').scoping do CoolCar.find(:first, :order => 'id asc') -- cgit v1.2.3