Skip to content

Commit 2192835

Browse files
committed
Stylistic changes
1 parent c586297 commit 2192835

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

lib/sendgrid/email.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,14 @@ defmodule SendGrid.Email do
141141
Adds an attachment to the email. An attachment is a map with the keys:
142142
* content
143143
* type
144-
filename
144+
* filename
145145
* disposition
146146
* content_id
147-
"""
148147
148+
attachment = %{content: "base64string", filename: "image.jpg"}
149+
Email.add_attachment(%Email{}, attachemnt}
150+
151+
"""
149152
@spec add_attachment(Email.t, Attachment.t) :: Email.t
150153
def add_attachment(%Email{} = email, attachment) do
151154
attachments = case email.attachments do

test/email_test.exs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,25 @@ defmodule SendGrid.Email.Test do
166166
|> SendGrid.Mailer.send()
167167
end
168168

169-
test "add_attachment" do
170-
attachment = %{content: "somebase64encodedstring", type: "image/jpeg", filename: "testing.jpg"}
171-
email = Email.build()
172-
|> Email.add_attachment(attachment)
173-
assert email.attachments == [attachment]
174-
assert Enum.count(email.attachments) == 1
175-
end
176-
177-
test "add_attachment multiple" do
178-
attachment1 = %{content: "somebase64encodedstring", type: "image/jpeg", filename: "testing.jpg"}
179-
attachment2 = %{content: "somebase64encodedstring2", type: "image/png", filename: "testing2.jpg"}
180-
email = Email.build()
181-
|> Email.add_attachment(attachment1)
182-
|> Email.add_attachment(attachment2)
183-
assert email.attachments == [attachment1, attachment2]
184-
assert Enum.count(email.attachments) == 2
169+
describe "add_attachemnt/2" do
170+
test "adds a single attachemnt" do
171+
attachment = %{content: "somebase64encodedstring", type: "image/jpeg", filename: "testing.jpg"}
172+
email =
173+
Email.build()
174+
|> Email.add_attachment(attachment)
175+
assert email.attachments == [attachment]
176+
assert Enum.count(email.attachments) == 1
177+
end
178+
179+
test "appends to attachment list" do
180+
attachment1 = %{content: "somebase64encodedstring", type: "image/jpeg", filename: "testing.jpg"}
181+
attachment2 = %{content: "somebase64encodedstring2", type: "image/png", filename: "testing2.jpg"}
182+
email =
183+
Email.build()
184+
|> Email.add_attachment(attachment1)
185+
|> Email.add_attachment(attachment2)
186+
assert email.attachments == [attachment1, attachment2]
187+
assert Enum.count(email.attachments) == 2
188+
end
185189
end
186190
end

0 commit comments

Comments
 (0)