diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-03-05 10:24:13 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-03-05 10:24:13 +0100 |
commit | f6aeb8b1a3687c8523e4a56309fe3736011b2935 (patch) | |
tree | 6e13a931827f71bb89d4522279aacb99793736c1 /activerecord/test/cases | |
parent | 8d486c63d63eeb503fd18be615d5dd26dfa34fb5 (diff) | |
download | rails-f6aeb8b1a3687c8523e4a56309fe3736011b2935.tar.gz rails-f6aeb8b1a3687c8523e4a56309fe3736011b2935.tar.bz2 rails-f6aeb8b1a3687c8523e4a56309fe3736011b2935.zip |
we only need to support `asc` and `ASC`. No need for mixed cases. #14263
This is a result of the discussion at https://github.com/rails/rails/pull/14263/files#r10291489
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index a08171cfcc..72b96dd3e9 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -205,31 +205,21 @@ class RelationTest < ActiveRecord::TestCase assert_equal [topics(:first), topics(:second), topics(:third), topics(:fourth), topics(:fifth)], topics.to_a end - def test_nothing_raises_on_upcase_desc_arg - Topic.order(id: "DESC") - end - - def test_nothing_raises_on_downcase_desc_arg - Topic.order(id: "desc") - end - - def test_nothing_raises_on_upcase_asc_arg - Topic.order(id: "ASC") - end - - def test_nothing_raises_on_downcase_asc_arg - Topic.order(id: "asc") - end + def test_support_upper_and_lower_case_directions + assert_includes Topic.order(id: "ASC").to_sql, "ASC" + assert_includes Topic.order(id: "asc").to_sql, "ASC" + assert_includes Topic.order(id: :ASC).to_sql, "ASC" + assert_includes Topic.order(id: :asc).to_sql, "ASC" - def test_nothing_raises_on_case_insensitive_args - Topic.order(id: "DeSc") - Topic.order(id: :DeSc) - Topic.order(id: "aSc") - Topic.order(id: :aSc) + assert_includes Topic.order(id: "DESC").to_sql, "DESC" + assert_includes Topic.order(id: "desc").to_sql, "DESC" + assert_includes Topic.order(id: :DESC).to_sql, "DESC" + assert_includes Topic.order(id: :desc).to_sql,"DESC" end def test_raising_exception_on_invalid_hash_params - assert_raise(ArgumentError) { Topic.order(:name, "id DESC", id: :asfsdf) } + e = assert_raise(ArgumentError) { Topic.order(:name, "id DESC", id: :asfsdf) } + assert_equal 'Direction "asfsdf" is invalid. Valid directions are: [:asc, :desc, :ASC, :DESC, "asc", "desc", "ASC", "DESC"]', e.message end def test_finding_last_with_arel_order |