diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-02-23 04:16:49 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-02-23 11:15:00 +0900 |
commit | 5ecbeda0e225e4961977b5c516088cf12d92319f (patch) | |
tree | 4bedfffeb0c9ac1a89245d01c749171f1c2f359d | |
parent | cfbde022eedde2ae45e2dde9e3d8792933f070f4 (diff) | |
download | rails-5ecbeda0e225e4961977b5c516088cf12d92319f.tar.gz rails-5ecbeda0e225e4961977b5c516088cf12d92319f.tar.bz2 rails-5ecbeda0e225e4961977b5c516088cf12d92319f.zip |
More exercise range predicate builder
* Add test case for open-ended range.
* Add test case for numeric range for string column.
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index b413212e26..ebddf81449 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -812,6 +812,15 @@ class FinderTest < ActiveRecord::TestCase assert_equal [1, 2, 6, 7, 8], Comment.where(id: [1..2, 6..8]).to_a.map(&:id).sort end + def test_find_on_hash_conditions_with_open_ended_range + assert_equal [1, 2, 3], Comment.where(id: Float::INFINITY..3).to_a.map(&:id).sort + end + + def test_find_on_hash_conditions_with_numeric_range_for_string + topic = Topic.create!(title: "12 Factor App") + assert_equal [topic], Topic.where(title: 10..2).to_a + end + def test_find_on_multiple_hash_conditions assert Topic.where(author_name: "David", title: "The First Topic", replies_count: 1, approved: false).find(1) assert_raise(ActiveRecord::RecordNotFound) { Topic.where(author_name: "David", title: "The First Topic", replies_count: 1, approved: true).find(1) } |