Skip to content

Commit

Permalink
fix: broken sends (#15)
Browse files Browse the repository at this point in the history
# Overview

Follow-up from #10. The methods that return the SMTP host and port were
written in a way that would return empty strings for non-custom SMTP
configs, which was not right. This corrects that mistake.
  • Loading branch information
nshki authored Jun 17, 2024
1 parent 06a6c1c commit 4436694
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/smtp_config/providers_supportable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ module SmtpConfig::ProvidersSupportable
#
# @return [String]
def address
host || PROVIDERS.dig(provider.to_sym, :address)
host.present? ? host : PROVIDERS.dig(provider.to_sym, :address)
end

# Returns the port of the SMTP provider.
#
# @return [Integer]
def provider_port
port || PROVIDERS.dig(provider.to_sym, :port)
port.present? ? port : PROVIDERS.dig(provider.to_sym, :port)
end

# Returns the authentication method of the SMTP provider.
Expand Down
6 changes: 4 additions & 2 deletions test/models/smtp_config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class SmtpConfigTest < ActiveSupport::TestCase
smtp_config = SmtpConfig.new \
provider: "gmail",
username: "test_username",
password: "test_password"
password: "test_password",
host: ""

assert_equal "smtp.gmail.com", smtp_config.address
end
Expand All @@ -90,7 +91,8 @@ class SmtpConfigTest < ActiveSupport::TestCase
smtp_config = SmtpConfig.new \
provider: "gmail",
username: "test_username",
password: "test_password"
password: "test_password",
port: ""

assert_equal 587, smtp_config.provider_port
end
Expand Down

0 comments on commit 4436694

Please sign in to comment.