Skip to content

Commit

Permalink
chore: remove config and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
doomspork committed Sep 25, 2024
1 parent d91e2db commit 8330981
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 56 deletions.
30 changes: 0 additions & 30 deletions config/config.exs

This file was deleted.

3 changes: 1 addition & 2 deletions lib/bamboo/adapters/mailgun_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ defmodule Bamboo.MailgunAdapter do
end

defp prepare_file(%Attachment{} = attachment) do
{"", attachment.data,
{"form-data", [{"name", ~s/"attachment"/}, {"filename", ~s/"#{attachment.filename}"/}]}, []}
{"", attachment.data, {"form-data", [{"name", ~s/"attachment"/}, {"filename", ~s/"#{attachment.filename}"/}]}, []}
end

@mailgun_message_fields ~w(from to cc bcc subject text html template recipient-variables)a
Expand Down
3 changes: 1 addition & 2 deletions lib/bamboo/adapters/send_grid_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ defmodule Bamboo.SendGridAdapter do
end

defp cast_address_as_map(address) do
case {Map.get(address, :name, Map.get(address, "name")),
Map.get(address, :email, Map.get(address, "email"))} do
case {Map.get(address, :name, Map.get(address, "name")), Map.get(address, :email, Map.get(address, "email"))} do
{_name, nil} ->
throw({:error, "Must specify at least an 'email' field in map #{inspect(address)}"})

Expand Down
4 changes: 1 addition & 3 deletions lib/bamboo/view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ defmodule Bamboo.View do

true ->
raise ArgumentError, """
Template name must end in either ".html" or ".text". Template name was #{
inspect(template)
}
Template name must end in either ".html" or ".text". Template name was #{inspect(template)}
If you would like to render both and html and text template,
use an atom without an extension instead.
Expand Down
3 changes: 1 addition & 2 deletions test/lib/bamboo/adapters/mailgun_helper_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ defmodule Bamboo.MailgunHelperTest do
})

assert email.private == %{
mailgun_recipient_variables:
"{\"user1@example.com\":{\"unique_id\":\"ABC123456789\"}}"
mailgun_recipient_variables: "{\"user1@example.com\":{\"unique_id\":\"ABC123456789\"}}"
}
end
end
15 changes: 6 additions & 9 deletions test/lib/bamboo/adapters/mandrill_adapter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,15 @@ defmodule Bamboo.MandrillAdapterTest do
)
|> Email.put_header("Reply-To", "reply@foo.com")
|> Email.put_attachment(file_path)
|> Email.put_attachment(
Attachment.new(file_path, content_id: "my_fake_image", filename: "fake_image.jpg")
)
|> Email.put_attachment(Attachment.new(file_path, content_id: "my_fake_image", filename: "fake_image.jpg"))
|> Email.put_attachment(%Attachment{
content_type: "image/png",
content_id: "my_image",
filename: "my_image.png",
data:
<<137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1,
8, 6, 0, 0, 0, 31, 21, 196, 137, 0, 0, 0, 13, 73, 68, 65, 84, 120, 218, 99, 252, 207,
192, 80, 15, 0, 4, 133, 1, 128, 132, 169, 140, 33, 0, 0, 0, 0, 73, 69, 78, 68, 174,
66, 96, 130>>
<<137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21,
196, 137, 0, 0, 0, 13, 73, 68, 65, 84, 120, 218, 99, 252, 207, 192, 80, 15, 0, 4, 133, 1, 128, 132, 169,
140, 33, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130>>
})

email |> MandrillAdapter.deliver(@config)
Expand Down Expand Up @@ -214,7 +211,7 @@ defmodule Bamboo.MandrillAdapterTest do
email =
new_email()
|> MandrillHelper.template("hello", [
%{name: 'example name', content: 'example content'}
%{name: ~c"example name", content: ~c"example content"}
])

email |> MandrillAdapter.deliver(@config)
Expand All @@ -228,7 +225,7 @@ defmodule Bamboo.MandrillAdapterTest do
}}

assert template_name == "hello"
assert template_content == [%{"content" => 'example content', "name" => 'example name'}]
assert template_content == [%{"content" => ~c"example content", "name" => ~c"example name"}]
end

test "returns an error if the response is not a success" do
Expand Down
12 changes: 4 additions & 8 deletions test/lib/bamboo/mailer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ defmodule Bamboo.MailerTest do
email = new_email(to: "foo@bar.com")
assert {:ok, %Bamboo.Email{blocked: false}} = Mailer.deliver_now(email)

assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "},
_config}
assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "}, _config}
end

@tag interceptors: [Bamboo.DenyListInterceptor, Bamboo.EnvInterceptor]
Expand All @@ -473,8 +472,7 @@ defmodule Bamboo.MailerTest do
email = new_email(to: "foo@bar.com")
assert %Bamboo.Email{blocked: false} = Mailer.deliver_now!(email)

assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "},
_config}
assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "}, _config}
end

@tag interceptors: [Bamboo.DenyListInterceptor, Bamboo.EnvInterceptor]
Expand All @@ -491,8 +489,7 @@ defmodule Bamboo.MailerTest do
email = new_email(to: "foo@bar.com")
assert {:ok, %Bamboo.Email{blocked: false}} = Mailer.deliver_later(email)

assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "},
_config}
assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "}, _config}
end

@tag interceptors: [Bamboo.DenyListInterceptor, Bamboo.EnvInterceptor]
Expand All @@ -509,8 +506,7 @@ defmodule Bamboo.MailerTest do
email = new_email(to: "foo@bar.com")
assert %Bamboo.Email{blocked: false} = Mailer.deliver_later!(email)

assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "},
_config}
assert_receive {:deliver, %Bamboo.Email{to: [{nil, "foo@bar.com"}], subject: "test - "}, _config}
end

@tag interceptors: [Bamboo.DenyListInterceptor, Bamboo.EnvInterceptor]
Expand Down

0 comments on commit 8330981

Please sign in to comment.