diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-12-06 13:54:09 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-12-06 13:54:09 -0800 |
commit | bb0c13bfdb11e2d8505f2fe87dab5ae8391e9264 (patch) | |
tree | 4725f6145f7716853122ed6a59f5afbc22edd786 | |
parent | 731bfa7cf45b8b849e63990d933fc65a14a6b860 (diff) | |
download | rails-bb0c13bfdb11e2d8505f2fe87dab5ae8391e9264.tar.gz rails-bb0c13bfdb11e2d8505f2fe87dab5ae8391e9264.tar.bz2 rails-bb0c13bfdb11e2d8505f2fe87dab5ae8391e9264.zip |
Address objects are value objects
-rw-r--r-- | lib/action_mailbox/mail_ext/address_equality.rb | 5 | ||||
-rw-r--r-- | test/unit/mail_ext/address_equality_test.rb | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/action_mailbox/mail_ext/address_equality.rb b/lib/action_mailbox/mail_ext/address_equality.rb new file mode 100644 index 0000000000..76675365dd --- /dev/null +++ b/lib/action_mailbox/mail_ext/address_equality.rb @@ -0,0 +1,5 @@ +class Mail::Address + def ==(other_address) + other_address.is_a?(Mail::Address) && to_s == other_address.to_s + end +end diff --git a/test/unit/mail_ext/address_equality_test.rb b/test/unit/mail_ext/address_equality_test.rb new file mode 100644 index 0000000000..56e9bfa47f --- /dev/null +++ b/test/unit/mail_ext/address_equality_test.rb @@ -0,0 +1,9 @@ +require_relative '../../test_helper' + +module MailExt + class AddressEqualityTest < ActiveSupport::TestCase + test "two addresses with the same address are equal" do + assert_equal Mail::Address.new("david@basecamp.com"), Mail::Address.new("david@basecamp.com") + end + end +end |