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
|
end
|
||||||
|
|
||||||
def invalid_rule?
|
def invalid_rule?
|
||||||
rule = routing_rule
|
!valid_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))
|
end
|
||||||
return true if !routing_rule_matches_tdc?
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
def non_unique_rule?
|
def non_unique_rule?
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe RoutingEngine, type: :model do
|
||||||
context 'without any matching rules' do
|
context 'without any matching rules' do
|
||||||
before do
|
before do
|
||||||
procedure.groupe_instructeurs.each do |gi|
|
procedure.groupe_instructeurs.each do |gi|
|
||||||
gi.update(routing_rule: constant(false))
|
gi.update(routing_rule: ds_eq(constant(false), constant(false)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue