[Fix #499] Attestation: add maxlength to footer
This commit is contained in:
parent
81984d2883
commit
3d99407495
4 changed files with 21 additions and 1 deletions
|
@ -7,6 +7,7 @@ class AttestationTemplate < ApplicationRecord
|
||||||
mount_uploader :signature, AttestationTemplateImageUploader
|
mount_uploader :signature, AttestationTemplateImageUploader
|
||||||
|
|
||||||
validate :logo_signature_file_size
|
validate :logo_signature_file_size
|
||||||
|
validates :footer, length: { maximum: 190 }
|
||||||
|
|
||||||
FILE_MAX_SIZE_IN_MB = 0.5
|
FILE_MAX_SIZE_IN_MB = 0.5
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :footer, 'Adresse en bas de page'
|
= f.label :footer, 'Adresse en bas de page'
|
||||||
= f.text_field :footer, class: 'form-control'
|
= f.text_field :footer, class: 'form-control', maxlength: 190
|
||||||
|
|
||||||
%button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser
|
%button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,10 @@ fr:
|
||||||
activerecord:
|
activerecord:
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
|
attestation_template:
|
||||||
|
attributes:
|
||||||
|
footer:
|
||||||
|
too_long: ": l'adresse en bas de page est trop longue."
|
||||||
piece_justificative:
|
piece_justificative:
|
||||||
attributes:
|
attributes:
|
||||||
content:
|
content:
|
||||||
|
|
|
@ -40,6 +40,21 @@ describe AttestationTemplate, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'validates footer length' do
|
||||||
|
let(:attestation_template) { AttestationTemplate.new(footer: footer) }
|
||||||
|
|
||||||
|
subject do
|
||||||
|
attestation_template.validate
|
||||||
|
attestation_template.errors.details
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the footer is too long' do
|
||||||
|
let(:footer) { 'a' * 191 }
|
||||||
|
|
||||||
|
it { is_expected.to match({ footer: [{ error: :too_long, count: 190 }] }) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'dup' do
|
describe 'dup' do
|
||||||
before do
|
before do
|
||||||
@logo = File.open('spec/fixtures/white.png')
|
@logo = File.open('spec/fixtures/white.png')
|
||||||
|
|
Loading…
Reference in a new issue