mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Fixed condition constains operator with wrong data type
"contains" operator on wrong data type should not cause NoMethodError.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## 3.0.0 / not yet released / branch "master"
|
||||
|
||||
* ...
|
||||
* Fixed condition with wrong data types, see #423 [Bogdan Gusiev]
|
||||
* Add url_encode to standard filters, see #421 [Derrick Reimer, djreimer]
|
||||
* Add uniq to standard filters [Florian Weingarten, fw42]
|
||||
* Add exception_handler feature, see #397 and #254 [Bogdan Gusiev, bogdan and Florian Weingarten, fw42]
|
||||
|
||||
@@ -15,7 +15,9 @@ module Liquid
|
||||
'>'.freeze => :>,
|
||||
'>='.freeze => :>=,
|
||||
'<='.freeze => :<=,
|
||||
'contains'.freeze => lambda { |cond, left, right| left && right ? left.include?(right) : false }
|
||||
'contains'.freeze => lambda { |cond, left, right|
|
||||
left && right && left.respond_to?(:include?) ? left.include?(right) : false
|
||||
}
|
||||
}
|
||||
|
||||
def self.operators
|
||||
|
||||
@@ -80,6 +80,10 @@ class ConditionUnitTest < Minitest::Test
|
||||
assert_evalutes_false "0", 'contains', 'not_assigned'
|
||||
end
|
||||
|
||||
def test_contains_return_false_on_wrong_data_type
|
||||
assert_evalutes_false "1", 'contains', '0'
|
||||
end
|
||||
|
||||
def test_or_condition
|
||||
condition = Condition.new('1', '==', '2')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user