aboutsummaryrefslogtreecommitdiffstats
path: root/test/attributes
diff options
context:
space:
mode:
Diffstat (limited to 'test/attributes')
-rw-r--r--test/attributes/test_attribute.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb
index 500f9385f8..e4ddb27e72 100644
--- a/test/attributes/test_attribute.rb
+++ b/test/attributes/test_attribute.rb
@@ -1,4 +1,5 @@
require 'helper'
+require 'ostruct'
module Arel
module Attributes
@@ -572,6 +573,16 @@ module Arel
)
end
+ it 'can be constructed with a quoted range starting from -Infinity' do
+ attribute = Attribute.new nil, nil
+ node = attribute.between(quoted_range(-::Float::INFINITY, 3, false))
+
+ node.must_equal Nodes::LessThanOrEqual.new(
+ attribute,
+ Nodes::Quoted.new(3)
+ )
+ end
+
it 'can be constructed with an exclusive range starting from -Infinity' do
attribute = Attribute.new nil, nil
node = attribute.between(-::Float::INFINITY...3)
@@ -582,6 +593,16 @@ module Arel
)
end
+ it 'can be constructed with a quoted exclusive range starting from -Infinity' do
+ attribute = Attribute.new nil, nil
+ node = attribute.between(quoted_range(-::Float::INFINITY, 3, true))
+
+ node.must_equal Nodes::LessThan.new(
+ attribute,
+ Nodes::Quoted.new(3)
+ )
+ end
+
it 'can be constructed with an infinite range' do
attribute = Attribute.new nil, nil
node = attribute.between(-::Float::INFINITY..::Float::INFINITY)
@@ -589,6 +610,14 @@ module Arel
node.must_equal Nodes::NotIn.new(attribute, [])
end
+ it 'can be constructed with a quoted infinite range' do
+ attribute = Attribute.new nil, nil
+ node = attribute.between(quoted_range(-::Float::INFINITY, ::Float::INFINITY, false))
+
+ node.must_equal Nodes::NotIn.new(attribute, [])
+ end
+
+
it 'can be constructed with a range ending at Infinity' do
attribute = Attribute.new nil, nil
node = attribute.between(0..::Float::INFINITY)
@@ -599,6 +628,16 @@ module Arel
)
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))
+
+ node.must_equal Nodes::GreaterThanOrEqual.new(
+ attribute,
+ Nodes::Quoted.new(0)
+ )
+ end
+
it 'can be constructed with an exclusive range' do
attribute = Attribute.new nil, nil
node = attribute.between(0...3)
@@ -614,6 +653,14 @@ module Arel
)
])
end
+
+ def quoted_range(begin_val, end_val, exclude)
+ OpenStruct.new(
+ begin: Nodes::Quoted.new(begin_val),
+ end: Nodes::Quoted.new(end_val),
+ exclude_end?: exclude,
+ )
+ end
end
describe '#in' do