Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add arbitrary header overrides for attachments #631

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add test for header overrides
jarrodmoldrich committed Nov 16, 2024
commit a77701869ad328f107211d0fe33c3d1125687b7e
4 changes: 2 additions & 2 deletions lib/bamboo/attachment.ex
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ defmodule Bamboo.Attachment do
filename: "image.png",
content_type: "image/png",
content_id: "<12387432>",
headers: [content_disposition, "inline", x_attachment_id: "12387432"]
headers: [content_disposition: "inline", x_attachment_id: "12387432"]
)
Bamboo.Attachment.new(params["file"]) # Where params["file"] is a %Plug.Upload

@@ -57,7 +57,7 @@ defmodule Bamboo.Attachment do
filename: "logo.png",
data: "content",
content_id: "<12387432>",
headers: [content_disposition, "inline", x_attachment_id: "12387432"]
headers: [content_disposition: "inline", x_attachment_id: "12387432"]
}
)
"""
17 changes: 17 additions & 0 deletions test/lib/bamboo/attachments_test.exs
Original file line number Diff line number Diff line change
@@ -58,4 +58,21 @@
assert attachment.filename == "my-attachment.doc"
assert attachment.data
end

test "create an attachment with headers and content ID (like an inline image)" do
path = Path.join(__DIR__, "../../support/attachment.docx")

attachment =
Attachment.new(
path,
filename: "image.png",
content_type: "image/png",
content_id: "<12387432>",
headers: [content_disposition: "inline", x_attachment_id: "12387432"]
)
|> IO.inspect()

Check warning on line 73 in test/lib/bamboo/attachments_test.exs

GitHub Actions / Credo

There should be no calls to `IO.inspect/1`.

assert attachment.content_id == "<12387432>"
assert [content_disposition: "inline", x_attachment_id: "12387432"] = attachment.headers
end
end