0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-14 13:52:54 +01:00

Merge pull request #60 from OrbitalOwen/bug-fix/min-length-composer

Add composer to valid text fields for min length option
Dieser Commit ist enthalten in:
Angus McLeod 2020-11-13 13:02:03 +11:00 committet von GitHub
Commit 542195a0e0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 18 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -333,7 +333,7 @@ class CustomWizard::Builder
end end
def is_text_type(field) def is_text_type(field)
['text', 'textarea'].include? field['type'] ['text', 'textarea', 'composer'].include? field['type']
end end
def is_url_type(field) def is_url_type(field)

Datei anzeigen

@ -318,11 +318,26 @@ describe CustomWizard::Builder do
end end
context 'validation' do context 'validation' do
it 'applies min length' do it 'applies min length to fields that support min length' do
min_length = 3
@template[:steps][0][:fields][0][:min_length] = min_length
@template[:steps][0][:fields][1][:min_length] = min_length
@template[:steps][0][:fields][2][:min_length] = min_length
CustomWizard::Template.save(@template.as_json)
expect( expect(
perform_update('step_1', step_1_field_1: 'Te') perform_update('step_1', step_1_field_1: 'Te')
.errors.messages[:step_1_field_1].first .errors.messages[:step_1_field_1].first
).to eq(I18n.t('wizard.field.too_short', label: 'Text', min: 3)) ).to eq(I18n.t('wizard.field.too_short', label: 'Text', min: min_length))
expect(
perform_update('step_1', step_1_field_2: 'Te')
.errors.messages[:step_1_field_2].first
).to eq(I18n.t('wizard.field.too_short', label: 'Textarea', min: min_length))
expect(
perform_update('step_1', step_1_field_3: 'Te')
.errors.messages[:step_1_field_3].first
).to eq(I18n.t('wizard.field.too_short', label: 'Composer', min: min_length))
end end
it 'standardises boolean entries' do it 'standardises boolean entries' do