mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 10:15:40 +03:00
'contains' operator returns false if either operand is nil
This commit is contained in:
@@ -15,7 +15,7 @@ module Liquid
|
||||
'>' => :>,
|
||||
'>=' => :>=,
|
||||
'<=' => :<=,
|
||||
'contains' => lambda { |cond, left, right| left.include?(right) },
|
||||
'contains' => lambda { |cond, left, right| left && right ? left.include?(right) : false }
|
||||
}
|
||||
|
||||
def self.operators
|
||||
|
||||
@@ -60,6 +60,12 @@ class ConditionTest < Test::Unit::TestCase
|
||||
|
||||
end
|
||||
|
||||
def test_contains_returns_false_for_nil_operands
|
||||
@context = Liquid::Context.new
|
||||
assert_evalutes_false "not_assigned", 'contains', '0'
|
||||
assert_evalutes_false "0", 'contains', 'not_assigned'
|
||||
end
|
||||
|
||||
def test_or_condition
|
||||
condition = Condition.new('1', '==', '2')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user