diff --git a/app/models/logic/binary_operator.rb b/app/models/logic/binary_operator.rb index d33d1088d..dcedcc631 100644 --- a/app/models/logic/binary_operator.rb +++ b/app/models/logic/binary_operator.rb @@ -33,7 +33,7 @@ class Logic::BinaryOperator < Logic::Term l = @left.compute(champs) r = @right.compute(champs) - l.send(operation, r) + l&.send(operation, r) || false end def to_s = "(#{@left} #{operation} #{@right})" diff --git a/spec/models/logic/binary_operator_spec.rb b/spec/models/logic/binary_operator_spec.rb index 0221fc64d..437900cd8 100644 --- a/spec/models/logic/binary_operator_spec.rb +++ b/spec/models/logic/binary_operator_spec.rb @@ -22,9 +22,12 @@ end describe Logic::GreaterThan do include Logic + let(:champ) { create(:champ_integer_number, value: nil) } + it 'computes' do expect(greater_than(constant(1), constant(1)).compute).to be(false) expect(greater_than(constant(2), constant(1)).compute).to be(true) + expect(greater_than(champ_value(champ.stable_id), constant(2)).compute([champ])).to be(false) end end