1
0
Fork 0

FIX: field validation was not working in backend (#165)

* FIX: field validation was not working in backend

* added tests
Dieser Commit ist enthalten in:
Faizaan Gagan 2021-12-07 14:20:34 +05:30 committet von GitHub
Ursprung 757b382345
Commit 00682fb4c2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 36 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -18,8 +18,8 @@ class CustomWizard::TemplateValidator
data[:steps].each do |step| data[:steps].each do |step|
check_required(step, :step) check_required(step, :step)
if data[:fields].present? if step[:fields].present?
data[:fields].each do |field| step[:fields].each do |field|
check_required(field, :field) check_required(field, :field)
end end
end end

Datei anzeigen

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
# name: discourse-custom-wizard # name: discourse-custom-wizard
# about: Create custom wizards # about: Create custom wizards
# version: 1.15.5 # version: 1.15.6
# authors: Angus McLeod # authors: Angus McLeod
# url: https://github.com/paviliondev/discourse-custom-wizard # url: https://github.com/paviliondev/discourse-custom-wizard
# contact emails: angus@thepavilion.io # contact emails: angus@thepavilion.io

Datei anzeigen

@ -45,4 +45,37 @@ describe CustomWizard::TemplateValidator do
CustomWizard::TemplateValidator.new(template).perform CustomWizard::TemplateValidator.new(template).perform
).to eq(false) ).to eq(false)
end end
context "steps" do
CustomWizard::TemplateValidator.required[:step].each do |attribute|
it "invalidates if \"#{attribute.to_s}\" is not present" do
template[:steps][0][attribute] = nil
expect(
CustomWizard::TemplateValidator.new(template).perform
).to eq(false)
end
end
end
context "fields" do
CustomWizard::TemplateValidator.required[:field].each do |attribute|
it "invalidates if \"#{attribute.to_s}\" is not present" do
template[:steps][0][:fields][0][attribute] = nil
expect(
CustomWizard::TemplateValidator.new(template).perform
).to eq(false)
end
end
end
context "actions" do
CustomWizard::TemplateValidator.required[:action].each do |attribute|
it "invalidates if \"#{attribute.to_s}\" is not present" do
template[:actions][0][attribute] = nil
expect(
CustomWizard::TemplateValidator.new(template).perform
).to eq(false)
end
end
end
end end