diff options
author | Greg Navis <contact@gregnavis.com> | 2019-01-09 18:17:40 +0100 |
---|---|---|
committer | Greg Navis <contact@gregnavis.com> | 2019-01-11 14:27:34 +0100 |
commit | 7110dbea008dd4b80d1764003935a3c97ab10f57 (patch) | |
tree | 5bffd50bc1a8126167fcfd650bcc84e88789442f /activerecord/test/cases/arel | |
parent | ea65d92f1924648e72f93bb0e8e5fc62a56d0bac (diff) | |
download | rails-7110dbea008dd4b80d1764003935a3c97ab10f57.tar.gz rails-7110dbea008dd4b80d1764003935a3c97ab10f57.tar.bz2 rails-7110dbea008dd4b80d1764003935a3c97ab10f57.zip |
Support endless ranges in where
This commit adds support for endless ranges, e.g. (1..), that were added
in Ruby 2.6. They're functionally equivalent to explicitly specifying
Float::INFINITY as the end of the range.
Diffstat (limited to 'activerecord/test/cases/arel')
-rw-r--r-- | activerecord/test/cases/arel/attributes/attribute_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/arel/attributes/attribute_test.rb b/activerecord/test/cases/arel/attributes/attribute_test.rb index 671e273543..6ad54ab5df 100644 --- a/activerecord/test/cases/arel/attributes/attribute_test.rb +++ b/activerecord/test/cases/arel/attributes/attribute_test.rb @@ -639,6 +639,18 @@ module Arel ) end + if Gem::Version.new("2.6.0") <= Gem::Version.new(RUBY_VERSION) + it "can be constructed with a range implicitly ending at Infinity" do + attribute = Attribute.new nil, nil + node = attribute.between(eval("0..")) # Use eval for compatibility with Ruby < 2.6 parser + + node.must_equal Nodes::GreaterThanOrEqual.new( + attribute, + Nodes::Casted.new(0, attribute) + ) + end + end + it "can be constructed with a quoted range ending at Infinity" do attribute = Attribute.new nil, nil node = attribute.between(quoted_range(0, ::Float::INFINITY, false)) |