DEV: Set limit for Invite#custom_message
This commit is contained in:
parent
b81c13280a
commit
d63ce56252
|
@ -31,6 +31,7 @@ class Invite < ActiveRecord::Base
|
||||||
|
|
||||||
validates_presence_of :invited_by_id
|
validates_presence_of :invited_by_id
|
||||||
validates :email, email: true, allow_blank: true
|
validates :email, email: true, allow_blank: true
|
||||||
|
validates :custom_message, length: { maximum: 1000 }
|
||||||
validate :ensure_max_redemptions_allowed
|
validate :ensure_max_redemptions_allowed
|
||||||
validate :valid_redemption_count
|
validate :valid_redemption_count
|
||||||
validate :valid_domain, if: :will_save_change_to_domain?
|
validate :valid_domain, if: :will_save_change_to_domain?
|
||||||
|
|
|
@ -12,6 +12,7 @@ RSpec.describe Invite do
|
||||||
describe "Validators" do
|
describe "Validators" do
|
||||||
it { is_expected.to validate_presence_of :invited_by_id }
|
it { is_expected.to validate_presence_of :invited_by_id }
|
||||||
it { is_expected.to rate_limit }
|
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
|
it "allows invites with valid emails" do
|
||||||
invite = Fabricate.build(:invite, email: "test@example.com", invited_by: user)
|
invite = Fabricate.build(:invite, email: "test@example.com", invited_by: user)
|
||||||
|
|
Loading…
Reference in New Issue