From d63ce562529cb78a515a0da984bd243532cdd639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Thu, 11 May 2023 12:09:26 +0200 Subject: [PATCH] DEV: Set limit for Invite#custom_message --- app/models/invite.rb | 1 + spec/models/invite_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/invite.rb b/app/models/invite.rb index fbe34461c43..66697d34dfb 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -31,6 +31,7 @@ class Invite < ActiveRecord::Base validates_presence_of :invited_by_id validates :email, email: true, allow_blank: true + validates :custom_message, length: { maximum: 1000 } validate :ensure_max_redemptions_allowed validate :valid_redemption_count validate :valid_domain, if: :will_save_change_to_domain? diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index 681ebadbf72..d467b30e8f4 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Invite do describe "Validators" do it { is_expected.to validate_presence_of :invited_by_id } it { is_expected.to rate_limit } + it { is_expected.to validate_length_of(:custom_message).is_at_most(1000) } it "allows invites with valid emails" do invite = Fabricate.build(:invite, email: "test@example.com", invited_by: user)