1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add address wrapping

Makes it easier to deal with addresses that may already have been converted
This commit is contained in:
David Heinemeier Hansson 2018-12-06 13:53:50 -08:00
parent a1d449e061
commit 731bfa7cf4
2 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,5 @@
class Mail::Address
def self.wrap(address)
address.is_a?(Mail::Address) ? address : Mail::Address.new(address)
end
end

View file

@ -0,0 +1,11 @@
require_relative '../../test_helper'
module MailExt
class AddressWrappingTest < ActiveSupport::TestCase
test "wrap" do
needing_wrapping = Mail::Address.wrap("david@basecamp.com")
wrapping_not_needed = Mail::Address.wrap(Mail::Address.new("david@basecamp.com"))
assert_equal needing_wrapping.address, wrapping_not_needed.address
end
end
end