FIX: Disallow none as a category slug

This commit is contained in:
Daniel Waterworth 2019-12-12 11:13:42 +00:00
parent 3ec2081059
commit 6aff510809
1 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class Category < ActiveRecord::Base class Category < ActiveRecord::Base
RESERVED_SLUGS = [
'none'
]
self.ignored_columns = %w{ self.ignored_columns = %w{
uploaded_meta_id uploaded_meta_id
suppress_from_latest suppress_from_latest
@ -59,6 +63,7 @@ class Category < ActiveRecord::Base
validate :permissions_compatibility_validator validate :permissions_compatibility_validator
validates :auto_close_hours, numericality: { greater_than: 0, less_than_or_equal_to: 87600 }, allow_nil: true validates :auto_close_hours, numericality: { greater_than: 0, less_than_or_equal_to: 87600 }, allow_nil: true
validates :slug, exclusion: { in: RESERVED_SLUGS }
after_create :create_category_definition after_create :create_category_definition