FIX: Allow longer TLDs
This commit is contained in:
parent
ab11cea5b9
commit
adb3810f67
|
@ -399,7 +399,7 @@ class Group < ActiveRecord::Base
|
|||
domains.each do |domain|
|
||||
domain.sub!(/^https?:\/\//, '')
|
||||
domain.sub!(/\/.*$/, '')
|
||||
self.errors.add :base, (I18n.t('groups.errors.invalid_domain', domain: domain)) unless domain =~ /\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\Z/i
|
||||
self.errors.add :base, (I18n.t('groups.errors.invalid_domain', domain: domain)) unless domain =~ /\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,24}(:[0-9]{1,5})?(\/.*)?\Z/i
|
||||
end
|
||||
self.automatic_membership_email_domains = domains.join("|")
|
||||
end
|
||||
|
|
|
@ -60,6 +60,11 @@ describe Group do
|
|||
expect(group.valid?).to eq true
|
||||
end
|
||||
|
||||
it "is valid for newer TLDs" do
|
||||
group.automatic_membership_email_domains = "discourse.institute"
|
||||
expect(group.valid?).to eq true
|
||||
end
|
||||
|
||||
it "is invalid for bad incoming email" do
|
||||
group.incoming_email = "foo.bar.org"
|
||||
expect(group.valid?).to eq(false)
|
||||
|
@ -234,20 +239,20 @@ describe Group do
|
|||
groups = Group.includes(:users).to_a
|
||||
expect(groups.count).to eq Group::AUTO_GROUPS.count
|
||||
|
||||
g = groups.find{|g| g.id == Group::AUTO_GROUPS[:admins]}
|
||||
g = groups.find{|grp| grp.id == Group::AUTO_GROUPS[:admins]}
|
||||
expect(g.users.count).to eq 2
|
||||
expect(g.user_count).to eq 2
|
||||
|
||||
g = groups.find{|g| g.id == Group::AUTO_GROUPS[:staff]}
|
||||
g = groups.find{|grp| grp.id == Group::AUTO_GROUPS[:staff]}
|
||||
expect(g.users.count).to eq 2
|
||||
expect(g.user_count).to eq 2
|
||||
|
||||
g = groups.find{|g| g.id == Group::AUTO_GROUPS[:trust_level_1]}
|
||||
g = groups.find{|grp| grp.id == Group::AUTO_GROUPS[:trust_level_1]}
|
||||
# admin, system and user
|
||||
expect(g.users.count).to eq 3
|
||||
expect(g.user_count).to eq 3
|
||||
|
||||
g = groups.find{|g| g.id == Group::AUTO_GROUPS[:trust_level_2]}
|
||||
g = groups.find{|grp| grp.id == Group::AUTO_GROUPS[:trust_level_2]}
|
||||
# system and user
|
||||
expect(g.users.count).to eq 2
|
||||
expect(g.user_count).to eq 2
|
||||
|
|
Loading…
Reference in New Issue