Skip to content

Commit 92027bd

Browse files
committed
Adjust delivery method to work with array values for from and to
1 parent bea184b commit 92027bd

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/userlist/delivery_method.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Userlist::DeliveryMethod
2-
attr_reader :userlist
3-
attr_reader :settings
2+
attr_reader :userlist, :settings
43

54
def initialize(settings = {})
65
@settings = settings
@@ -26,7 +25,7 @@ def serialize(mail)
2625
end
2726

2827
def serialize_address(address)
29-
address.first.to_s
28+
Array(address).map(&:to_s)
3029
end
3130

3231
def serialize_body(body)

spec/userlist/delivery_method_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
it 'delivers the message correctly' do
2929
expected_payload = {
30-
to: 'user@example.com',
31-
from: 'sender@example.com',
30+
to: ['user@example.com'],
31+
from: ['sender@example.com'],
3232
subject: 'Test Subject',
3333
body: { type: :text, content: 'Hello world' },
3434
theme: nil
@@ -55,8 +55,8 @@
5555

5656
it 'delivers the message correctly' do
5757
expected_payload = {
58-
to: 'user@example.com',
59-
from: 'sender@example.com',
58+
to: ['user@example.com'],
59+
from: ['sender@example.com'],
6060
subject: 'Test Subject',
6161
body: { type: :html, content: '<p>Hello world</p>' },
6262
theme: nil
@@ -87,8 +87,8 @@
8787

8888
it 'delivers the message correctly' do
8989
expected_payload = {
90-
to: 'user@example.com',
91-
from: 'sender@example.com',
90+
to: ['user@example.com'],
91+
from: ['sender@example.com'],
9292
subject: 'Test Subject',
9393
body: {
9494
type: :multipart,

0 commit comments

Comments
 (0)