DEV: Set limit for Invite#custom_message

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

View File

@ -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?

View File

@ -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)