mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
More exercise range predicate builder
* Add test case for open-ended range. * Add test case for numeric range for string column.
This commit is contained in:
parent
cfbde022ee
commit
5ecbeda0e2
1 changed files with 9 additions and 0 deletions
|
@ -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) }
|
||||
|
|
Loading…
Reference in a new issue