DEV: Set limits for text fields in reviewables

This commit is contained in:
Loïc Guitaut 2023-04-27 17:46:25 +02:00 committed by Loïc Guitaut
parent b4cf990a51
commit 783c935dcb
2 changed files with 6 additions and 0 deletions

View File

@ -36,6 +36,8 @@ class Reviewable < ActiveRecord::Base
enum :priority, { low: 0, medium: 5, high: 10 }, scopes: false, suffix: true
enum :sensitivity, { disabled: 0, low: 9, medium: 6, high: 3 }, scopes: false, suffix: true
validates :reject_reason, length: { maximum: 500 }
after_create { log_history(:created, created_by) }
after_commit(on: :create) { DiscourseEvent.trigger(:reviewable_created, self) }

View File

@ -1,6 +1,10 @@
# frozen_string_literal: true
RSpec.describe Reviewable, type: :model do
describe "Validations" do
it { is_expected.to validate_length_of(:reject_reason).is_at_most(500) }
end
describe ".create" do
fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) }