fix(Champs::EngagementJuridiqueChamp): validates Champs::EngagementJuridiqueChamp respecting it's validation context.

This commit is contained in:
mfo 2024-04-01 07:17:39 +02:00
parent ff527517c9
commit 284a10e235
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
2 changed files with 2 additions and 2 deletions

View file

@ -3,5 +3,5 @@ class Champs::EngagementJuridiqueChamp < Champ
validates_with ExpressionReguliereValidator, validates_with ExpressionReguliereValidator,
expression_reguliere: /([A-Z]|[0-9]|\-|\_|\+|\/)+/, expression_reguliere: /([A-Z]|[0-9]|\-|\_|\+|\/)+/,
expression_reguliere_error_message: "Le numéro d'EJ ne peut contenir que des caractères alphanumérique et les caractères spéciaux suivant : “-“ ; “_“ ; “+“ ; “/“", expression_reguliere_error_message: "Le numéro d'EJ ne peut contenir que des caractères alphanumérique et les caractères spéciaux suivant : “-“ ; “_“ ; “+“ ; “/“",
if: -> { validation_context != :brouillon } if: :validate_champ_value?
end end

View file

@ -1,7 +1,7 @@
describe Champs::EngagementJuridiqueChamp do describe Champs::EngagementJuridiqueChamp do
describe 'validation' do describe 'validation' do
let(:champ) { build(:champ_engagement_juridique, value: value) } let(:champ) { build(:champ_engagement_juridique, value: value) }
subject { champ.valid? } subject { champ.validate(:champs_public_value) }
context 'with [A-Z]' do context 'with [A-Z]' do
let(:value) { "ABC" } let(:value) { "ABC" }