Merge pull request #7582 from betagouv/conditional_small_fixes

fix(conditionnel): fait marcher les operateurs lorsque les usagers n'ont pas remplis les champs
This commit is contained in:
Paul Chavard 2022-07-19 10:16:07 +02:00 committed by GitHub
commit 24d7cbb4e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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})"

View file

@ -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