refactor(groupe instructeur): add valid_rule? method
Co-authored-by: LeSim <mail@simon.lehericey.net>
This commit is contained in:
parent
0cab4d9807
commit
32b446deee
2 changed files with 7 additions and 4 deletions
|
@ -73,9 +73,12 @@ class GroupeInstructeur < ApplicationRecord
|
|||
end
|
||||
|
||||
def invalid_rule?
|
||||
rule = routing_rule
|
||||
return true if !((rule.is_a?(Logic::Eq) || rule.is_a?(Logic::NotEq)) && rule.left.is_a?(Logic::ChampValue) && rule.right.is_a?(Logic::Constant))
|
||||
return true if !routing_rule_matches_tdc?
|
||||
!valid_rule?
|
||||
end
|
||||
|
||||
def valid_rule?
|
||||
return false if routing_rule.nil?
|
||||
([routing_rule.left, routing_rule, routing_rule.right] in [ChampValue, Eq | NotEq, Constant]) && routing_rule_matches_tdc?
|
||||
end
|
||||
|
||||
def non_unique_rule?
|
||||
|
|
|
@ -28,7 +28,7 @@ describe RoutingEngine, type: :model do
|
|||
context 'without any matching rules' do
|
||||
before do
|
||||
procedure.groupe_instructeurs.each do |gi|
|
||||
gi.update(routing_rule: constant(false))
|
||||
gi.update(routing_rule: ds_eq(constant(false), constant(false)))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue