From cbfa8c4904f691aad1896eb99539ddbce67f7b11 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 27 Mar 2020 12:46:56 -0500 Subject: [PATCH] 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. --- app/logical/email_validator.rb | 4 ++++ test/unit/email_validator_test.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/logical/email_validator.rb b/app/logical/email_validator.rb index 7af1bbda3..313248be6 100644 --- a/app/logical/email_validator.rb +++ b/app/logical/email_validator.rb @@ -63,6 +63,10 @@ module EmailValidator "gmx.us" => "gmx.net", } + def smtp_enabled? + Rails.env.production? + end + def normalize(address) return nil unless address.count("@") == 1 diff --git a/test/unit/email_validator_test.rb b/test/unit/email_validator_test.rb index cf1bf0557..77392c08c 100644 --- a/test/unit/email_validator_test.rb +++ b/test/unit/email_validator_test.rb @@ -2,6 +2,10 @@ 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"))