FIX: field validation was not working in backend (#165)
* FIX: field validation was not working in backend * added tests
Dieser Commit ist enthalten in:
Ursprung
757b382345
Commit
00682fb4c2
3 geänderte Dateien mit 36 neuen und 3 gelöschten Zeilen
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Laden …
In neuem Issue referenzieren