Skip to content

Commit 8dc241a

Browse files
committed
Test custom type lookup is case-agnostic
To guarantee interoperatibility with current attribute and block schemas, ensure that custom type lookup for validation is case insensitive.
1 parent 029509e commit 8dc241a

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

spec/lib/canvas/validators/schema_attribute_spec.rb

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,28 @@
450450
}
451451
}
452452

453-
it "returns true" do
454-
expect(validator.validate).to eq(true)
453+
%w[card Card].each do |key|
454+
%w[card Card].each do |type|
455+
it "resolves type declaration #{type} when type key is #{key}" do
456+
card_type["key"] = key
457+
attribute["type"] = type
458+
expect(validator.validate).to eq(true)
459+
end
460+
end
461+
end
462+
463+
context "when the type is undefined" do
464+
let(:attribute) {
465+
{
466+
"name" => "my_card",
467+
"type" => "undefined_custom_type"
468+
}
469+
}
470+
471+
it "marks undefined type references as invalid" do
472+
expect(validator.validate).to eq(false)
473+
expect(validator.errors).to include(/"type" must be one of: .*, card/)
474+
end
455475
end
456476

457477
context "when array is true and custom type includes nonarray supported types" do

0 commit comments

Comments
 (0)