DEV: Set limits for text fields on BadgeGrouping

This commit is contained in:
Loïc Guitaut 2023-05-11 11:33:00 +02:00 committed by Loïc Guitaut
parent 1106e4ad09
commit b81c13280a
2 changed files with 11 additions and 0 deletions

View File

@ -9,6 +9,9 @@ class BadgeGrouping < ActiveRecord::Base
has_many :badges has_many :badges
validates :name, length: { maximum: 100 }
validates :description, length: { maximum: 500 }
def system? def system?
id && id <= 5 id && id <= 5
end end

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
require "rails_helper"
RSpec.describe BadgeGrouping, type: :model do
it { is_expected.to validate_length_of(:name).is_at_most(100) }
it { is_expected.to validate_length_of(:description).is_at_most(500) }
end