Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-14 22:02:53 +01:00
Fix required fields with blank string values
Dieser Commit ist enthalten in:
Ursprung
da7153fe34
Commit
c150c83578
2 geänderte Dateien mit 11 neuen und 1 gelöschten Zeilen
|
@ -28,7 +28,7 @@ class ::CustomWizard::UpdateValidator
|
||||||
file_types = field.file_types
|
file_types = field.file_types
|
||||||
format = field.format
|
format = field.format
|
||||||
|
|
||||||
if required && !value
|
if required && !value.present?
|
||||||
@updater.errors.add(field_id, I18n.t('wizard.field.required', label: label))
|
@updater.errors.add(field_id, I18n.t('wizard.field.required', label: label))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,16 @@ describe CustomWizard::UpdateValidator do
|
||||||
).to eq(I18n.t('wizard.field.required', label: 'Textarea'))
|
).to eq(I18n.t('wizard.field.required', label: 'Textarea'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'requires required fields with blank string values' do
|
||||||
|
@template[:steps][0][:fields][1][:required] = true
|
||||||
|
CustomWizard::Template.save(@template)
|
||||||
|
|
||||||
|
updater = perform_validation('step_1', step_1_field_2: "")
|
||||||
|
expect(
|
||||||
|
updater.errors.messages[:step_1_field_2].first
|
||||||
|
).to eq(I18n.t('wizard.field.required', label: 'Textarea'))
|
||||||
|
end
|
||||||
|
|
||||||
context "subscription fields" do
|
context "subscription fields" do
|
||||||
before do
|
before do
|
||||||
enable_subscription("standard")
|
enable_subscription("standard")
|
||||||
|
|
Laden …
In neuem Issue referenzieren