From b81c13280acf71f9eb36a619358e7762cf35d121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Thu, 11 May 2023 11:33:00 +0200 Subject: [PATCH] DEV: Set limits for text fields on BadgeGrouping --- app/models/badge_grouping.rb | 3 +++ spec/models/badge_grouping_spec.rb | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 spec/models/badge_grouping_spec.rb diff --git a/app/models/badge_grouping.rb b/app/models/badge_grouping.rb index c0afcbdbb10..cb60e4f715c 100644 --- a/app/models/badge_grouping.rb +++ b/app/models/badge_grouping.rb @@ -9,6 +9,9 @@ class BadgeGrouping < ActiveRecord::Base has_many :badges + validates :name, length: { maximum: 100 } + validates :description, length: { maximum: 500 } + def system? id && id <= 5 end diff --git a/spec/models/badge_grouping_spec.rb b/spec/models/badge_grouping_spec.rb new file mode 100644 index 00000000000..58b5dbdb343 --- /dev/null +++ b/spec/models/badge_grouping_spec.rb @@ -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