mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:04:11 +08:00
DEV: set limits for text fields on groups
This commit is contained in:
parent
2ccc5fc66e
commit
a89b3c27aa
|
@ -89,6 +89,10 @@ class Group < ActiveRecord::Base
|
|||
validate :incoming_email_validator
|
||||
validate :can_allow_membership_requests, if: :allow_membership_requests
|
||||
validate :validate_grant_trust_level, if: :will_save_change_to_grant_trust_level?
|
||||
validates :automatic_membership_email_domains, length: { maximum: 100 }
|
||||
validates :bio_raw, length: { maximum: 3000 }
|
||||
validates :membership_request_template, length: { maximum: 500 }
|
||||
validates :full_name, length: { maximum: 100 }
|
||||
|
||||
AUTO_GROUPS = {
|
||||
everyone: 0,
|
||||
|
|
|
@ -6,6 +6,14 @@ RSpec.describe Group do
|
|||
let(:group) { Fabricate(:group) }
|
||||
|
||||
describe "Validations" do
|
||||
it { is_expected.to allow_value("#{"a" * 96}.com").for(:automatic_membership_email_domains) }
|
||||
it do
|
||||
is_expected.not_to allow_value("#{"a" * 97}.com").for(:automatic_membership_email_domains)
|
||||
end
|
||||
it { is_expected.to validate_length_of(:bio_raw).is_at_most(3000) }
|
||||
it { is_expected.to validate_length_of(:membership_request_template).is_at_most(500) }
|
||||
it { is_expected.to validate_length_of(:full_name).is_at_most(100) }
|
||||
|
||||
describe "#grant_trust_level" do
|
||||
describe "when trust level is not valid" do
|
||||
it "should not be valid" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user