Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/valid_email2/email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def validate_each(record, attribute, value)
end

if options[:disposable_with_allow_list]
error(record, attribute, :disposable_with_allow_list) && return if addresses.any? { |address| address.disposable? && !address.allow_listed? }
error(record, attribute, :disposable_with_allow_list) && return if addresses.any? { |address| !address.allow_listed? && address.disposable? }
end

if options[:disposable_domain_with_allow_list]
Expand Down
8 changes: 8 additions & 0 deletions spec/valid_email2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ def set_allow_list
expect(user.valid?).to be_truthy
end

it "does not look up MX servers if the domain is in the allow list" do
File.open(allow_list_file_path, "w") { |f| f.write ["gmail.com"].to_yaml }
set_allow_list
expect_any_instance_of(ValidEmail2::Dns).not_to receive(:mx_servers)
user = TestUserDisallowDisposableWithAllowList.new(email: "foo@gmail.com")
expect(user.valid?).to be_truthy
end

it "is invalid if the domain is a disposable_domain and not in the allow list" do
user = TestUserDisallowDisposableDomainWithAllowList.new(email: "foo@#{allow_list_domain}")
expect(user.valid?).to be_falsey
Expand Down
Loading