Merge pull request #2864 from techAPJ/patch-3

FIX: invite email should be verified against `email_domains_blacklist`
This commit is contained in:
Robin Ward 2014-10-09 11:24:04 -04:00
commit e8637344c3
3 changed files with 23 additions and 1 deletions

View File

@ -98,7 +98,13 @@ module Jobs
email = csv_info[0]
group_ids = get_group_ids(csv_info[1], csv_line_number)
topic = get_topic(csv_info[2], csv_line_number)
begin
Invite.invite_by_email(email, @current_user, topic, group_ids)
rescue => e
log "Error inviting '#{email}' -- #{e}"
@sent -= 1
@failed += 1
end
end
def log(message)

View File

@ -10,6 +10,7 @@ class Invite < ActiveRecord::Base
has_many :topic_invites
has_many :topics, through: :topic_invites, source: :topic
validates_presence_of :invited_by_id
validates :email, email: true
before_create do
self.invite_key ||= SecureRandom.hex

View File

@ -21,6 +21,21 @@ describe Invite do
end
context 'email validators' do
let(:coding_horror) { Fabricate(:coding_horror) }
let(:invite) { Invite.create(email: "test@mailinator.com", invited_by: coding_horror) }
it "should not allow an invite with blacklisted email" do
invite.should_not be_valid
end
it "should allow an invite with non-blacklisted email" do
invite = Fabricate(:invite, email: "test@mail.com", invited_by: coding_horror)
invite.should be_valid
end
end
context '#create' do
context 'saved' do