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:
parent
a1d449e061
commit
731bfa7cf4
2 changed files with 16 additions and 0 deletions
5
lib/action_mailbox/mail_ext/address_wrapping.rb
Normal file
5
lib/action_mailbox/mail_ext/address_wrapping.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Mail::Address
|
||||
def self.wrap(address)
|
||||
address.is_a?(Mail::Address) ? address : Mail::Address.new(address)
|
||||
end
|
||||
end
|
11
test/unit/mail_ext/address_wrapping_test.rb
Normal file
11
test/unit/mail_ext/address_wrapping_test.rb
Normal 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
|
Loading…
Reference in a new issue