Make path validation case-insensitive

This commit is contained in:
Bob Van Landuyt 2017-04-14 20:06:20 +02:00
parent 27f54bebb2
commit c5059cb4f7
2 changed files with 8 additions and 1 deletions

View File

@ -94,6 +94,7 @@ class DynamicPathValidator < ActiveModel::EachValidator
end
def self.reserved?(value, type: :strict)
value = value.to_s.downcase
case type
when :wildcard
WILDCARD_ROUTES.include?(value)

View File

@ -81,7 +81,13 @@ describe DynamicPathValidator do
end
end
describe '#valid_full_path' do
describe ".valid?" do
it 'is not case sensitive' do
expect(described_class.valid?("Users", type: :top_level)).to be(false)
end
end
describe '.valid_full_path' do
it "isn't valid when the top level is reserved" do
test_path = 'u/should-be-a/reserved-word'