Files
danbooru/test/unit/email_validator_test.rb
evazion cbfa8c4904 email validator: fix undeliverable? method always returning false.
`undeliverable?` calls `smtp_enabled?` which we forgot to define. It
swallowed the error so it didn't fail but it always returned false.
2020-03-27 12:47:35 -05:00

28 lines
1.1 KiB
Ruby

require 'test_helper'
class EmailValidatorTest < ActiveSupport::TestCase
context "EmailValidator" do
setup do
EmailValidator.stubs(:smtp_enabled?).returns(true)
end
context "#undeliverable?" do
should "return good addresses as deliverable" do
assert_equal(false, EmailValidator.undeliverable?("webmaster@danbooru.donmai.us"))
assert_equal(false, EmailValidator.undeliverable?("noizave+spam@gmail.com"))
end
should "return nonexistent domains as undeliverable" do
assert_equal(true, EmailValidator.undeliverable?("nobody@does.not.exist.donmai.us"))
end
# XXX these tests are known to fail if your network blocks port 25.
should_eventually "return nonexistent addresses as undeliverable" do
assert_equal(true, EmailValidator.undeliverable?("does.not.exist.13yoigo34iy@gmail.com"))
assert_equal(true, EmailValidator.undeliverable?("does.not.exist.13yoigo34iy@outlook.com"))
assert_equal(true, EmailValidator.undeliverable?("does.not.exist.13yoigo34iy@hotmail.com"))
end
end
end
end