DEV: Define form template field inputs (#20430)

This commit is contained in:
Keegan George
2023-03-01 11:07:13 -08:00
committed by GitHub
parent 8b67a534a0
commit 666b4a7e6b
37 changed files with 963 additions and 130 deletions

View File

@ -4,17 +4,29 @@ require "rails_helper"
RSpec.describe FormTemplate, type: :model do
it "can't have duplicate names" do
Fabricate(:form_template, name: "Bug Report", template: "some yaml: true")
t = Fabricate.build(:form_template, name: "Bug Report", template: "some yaml: true")
Fabricate(:form_template, name: "Bug Report", template: "- type: input")
t = Fabricate.build(:form_template, name: "Bug Report", template: "- type: input")
expect(t.save).to eq(false)
t = Fabricate.build(:form_template, name: "Bug Report", template: "some yaml: true")
t = Fabricate.build(:form_template, name: "Bug Report", template: "- type: input")
expect(t.save).to eq(false)
expect(described_class.count).to eq(1)
end
it "can't have an invalid yaml template" do
template = "first: good\nsecond; bad"
template = "- type: checkbox\nattributes; bad"
t = Fabricate.build(:form_template, name: "Feature Request", template: template)
expect(t.save).to eq(false)
end
it "must have a supported type" do
template = "- type: fancy"
t = Fabricate.build(:form_template, name: "Fancy Template", template: template)
expect(t.save).to eq(false)
end
it "must have a type propety" do
template = "- hello: world"
t = Fabricate.build(:form_template, name: "Basic Template", template: template)
expect(t.save).to eq(false)
end
end