Skip to content

Commit

Permalink
Fixed parentheses deprecations for elixir 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
leaexplores committed Jan 4, 2017
1 parent ce913d1 commit ec518ec
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 85 deletions.
2 changes: 1 addition & 1 deletion lib/bamboo/adapters/sendgrid_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defmodule Bamboo.SendgridAdapter do
def deliver(email, config) do
api_key = get_key(config)
body = email |> to_sendgrid_body |> Plug.Conn.Query.encode
url = [base_uri, @send_message_path]
url = [base_uri(), @send_message_path]

case :hackney.post(url, headers(api_key), body, [:with_body]) do
{:ok, status, _headers, response} when status > 299 ->
Expand Down
2 changes: 1 addition & 1 deletion lib/bamboo/adapters/test_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Bamboo.TestAdapter do
@doc false
def deliver(email, _config) do
email = clean_assigns(email)
send test_process, {:delivered_email, email}
send test_process(), {:delivered_email, email}
end

defp test_process do
Expand Down
4 changes: 2 additions & 2 deletions lib/bamboo/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ defmodule Bamboo.Mailer do

@spec deliver_now(Bamboo.Email.t) :: Bamboo.Email.t
def deliver_now(email) do
config = build_config
config = build_config()
Bamboo.Mailer.deliver_now(config.adapter, email, config)
end

@spec deliver_later(Bamboo.Email.t) :: Bamboo.Email.t
def deliver_later(email) do
config = build_config
config = build_config()
Bamboo.Mailer.deliver_later(config.adapter, email, config)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bamboo/phoenix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defmodule Bamboo.Phoenix do
import Bamboo.Email, only: [put_private: 3]

defmacro __using__(view: view_module) do
verify_phoenix_dep
verify_phoenix_dep()
quote do
import Bamboo.Email
import Bamboo.Phoenix, except: [render: 3]
Expand Down
8 changes: 4 additions & 4 deletions lib/bamboo/plug/email_preview_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ defmodule Bamboo.EmailPreviewPlug do
plug :dispatch

get "/" do
if Enum.empty?(all_emails) do
if Enum.empty?(all_emails()) do
conn |> render(:ok, "no_emails.html")
else
conn |> render(:ok, "index.html", emails: all_emails, selected_email: newest_email)
conn |> render(:ok, "index.html", emails: all_emails(), selected_email: newest_email())
end
end

get "/:id" do
if email = SentEmail.get(id) do
conn |> render(:ok, "index.html", emails: all_emails, selected_email: email)
conn |> render(:ok, "index.html", emails: all_emails(), selected_email: email)
else
conn |> render(:not_found, "email_not_found.html")
end
Expand All @@ -67,7 +67,7 @@ defmodule Bamboo.EmailPreviewPlug do
end

defp newest_email do
all_emails |> List.first
all_emails() |> List.first
end

defp render(conn, status, template_name, assigns \\ []) do
Expand Down
6 changes: 3 additions & 3 deletions lib/bamboo/sent_email.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ defmodule Bamboo.SentEmail do
end

defp do_get(id) do
Enum.find all, nil, fn(email) ->
Enum.find all(), nil, fn(email) ->
email |> get_id |> String.downcase == String.downcase(id)
end
end
Expand All @@ -113,7 +113,7 @@ defmodule Bamboo.SentEmail do
end

defp put_rand_id(email) do
email |> Bamboo.Email.put_private(:local_adapter_id, rand_id)
email |> Bamboo.Email.put_private(:local_adapter_id, rand_id())
end

defp rand_id do
Expand All @@ -129,7 +129,7 @@ defmodule Bamboo.SentEmail do
there are 2 or more emails.
"""
def one do
case all do
case all() do
[email] -> email
[] -> raise NoDeliveriesError
emails -> raise DeliveriesError, emails
Expand Down
2 changes: 1 addition & 1 deletion lib/bamboo/strategies/task_supervisor_strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Bamboo.TaskSupervisorStrategy do

@doc false
def deliver_later(adapter, email, config) do
Task.Supervisor.start_child supervisor_name, fn ->
Task.Supervisor.start_child supervisor_name(), fn ->
adapter.deliver(email, config)
end
end
Expand Down
16 changes: 8 additions & 8 deletions lib/bamboo/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ defmodule Bamboo.Test do

@doc false
def flunk_with_email_list(email) do
if Enum.empty?(delivered_emails) do
flunk_no_emails_received
if Enum.empty?(delivered_emails()) do
flunk_no_emails_received()
else
flunk """
There were no matching emails.
Expand All @@ -207,7 +207,7 @@ defmodule Bamboo.Test do
Delivered emails:
#{delivered_emails_as_list}
#{delivered_emails_as_list()}
"""
end
end
Expand Down Expand Up @@ -244,15 +244,15 @@ defmodule Bamboo.Test do
end

defp delivered_emails do
{:messages, messages} = Process.info(self, :messages)
{:messages, messages} = Process.info(self(), :messages)

for {:delivered_email, _} = email_message <- messages do
email_message
end
end

defp delivered_emails_as_list do
delivered_emails |> add_asterisk |> Enum.join("\n")
delivered_emails() |> add_asterisk |> Enum.join("\n")
end

defp add_asterisk(emails) do
Expand All @@ -276,7 +276,7 @@ defmodule Bamboo.Test do
receive do
{:delivered_email, email} -> flunk_with_unexpected_email(email)
after
refute_timeout -> true
refute_timeout() -> true
end
end

Expand Down Expand Up @@ -317,7 +317,7 @@ defmodule Bamboo.Test do
receive do
{:delivered_email, ^email} -> flunk_with_unexpected_matching_email(email)
after
refute_timeout -> true
refute_timeout() -> true
end
end

Expand All @@ -332,7 +332,7 @@ defmodule Bamboo.Test do
end

defp refute_timeout do
if using_shared_mode? do
if using_shared_mode?() do
Application.get_env(:bamboo, :refute_timeout) || raise """
When using shared mode with Bamboo.Test, you must set a timeout. This
is because an email can be delivered after the assertion is called.
Expand Down
4 changes: 2 additions & 2 deletions lib/mix/start_email_preview_task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ defmodule Mix.Tasks.Bamboo.StartEmailPreview do
end

IO.puts "Running email preview on port 4003"
no_halt
no_halt()
end

defp no_halt do
unless iex_running?, do: :timer.sleep(:infinity)
unless iex_running?(), do: :timer.sleep(:infinity)
end

defp iex_running? do
Expand Down
8 changes: 4 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ defmodule Bamboo.Mixfile do
" Works with Mandrill, Mailgun, SendGrid, SparkPost, Postmark, in-memory, and test.",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
package: package,
package: package(),
docs: [main: "readme", extras: ["README.md"]],
deps: deps]
deps: deps()]
end

defp compilers(:test), do: [:phoenix] ++ Mix.compilers
Expand All @@ -43,8 +43,8 @@ defmodule Bamboo.Mixfile do
]
end

defp elixirc_paths(:test), do: elixirc_paths ++ ["test/support"]
defp elixirc_paths(_), do: elixirc_paths
defp elixirc_paths(:test), do: elixirc_paths() ++ ["test/support"]
defp elixirc_paths(_), do: elixirc_paths()
defp elixirc_paths, do: ["lib"]

defp deps do
Expand Down
8 changes: 3 additions & 5 deletions test/lib/bamboo/adapters/mailgun_adapter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ defmodule Bamboo.MailgunAdapterTest do
alias Bamboo.MailgunAdapter

@config %{adapter: MailgunAdapter, api_key: "dummyapikey", domain: "test.tt"}
@config_with_bad_key %{@config | api_key: nil}
@config_with_bad_domain %{@config | domain: nil}

defmodule FakeMailgun do
use Plug.Router
Expand All @@ -20,7 +18,7 @@ defmodule Bamboo.MailgunAdapterTest do
def start_server(parent) do
Agent.start_link(fn -> Map.new end, name: __MODULE__)
Agent.update(__MODULE__, &Map.put(&1, :parent, parent))
port = get_free_port
port = get_free_port()
Application.put_env(:bamboo, :mailgun_base_uri, "http://localhost:#{port}/")
Plug.Adapters.Cowboy.http __MODULE__, [], port: port, ref: __MODULE__
end
Expand Down Expand Up @@ -51,7 +49,7 @@ defmodule Bamboo.MailgunAdapterTest do
end

setup do
FakeMailgun.start_server(self)
FakeMailgun.start_server(self())

on_exit fn ->
FakeMailgun.shutdown
Expand All @@ -73,7 +71,7 @@ defmodule Bamboo.MailgunAdapterTest do
end

test "deliver/2 sends the to the right url" do
new_email |> MailgunAdapter.deliver(@config)
new_email() |> MailgunAdapter.deliver(@config)

assert_receive {:fake_mailgun, %{request_path: request_path}}

Expand Down
12 changes: 6 additions & 6 deletions test/lib/bamboo/adapters/mandrill_adapter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule Bamboo.MandrillAdapterTest do
end

setup do
FakeMandrill.start_server(self)
FakeMandrill.start_server(self())

on_exit fn ->
FakeMandrill.shutdown
Expand All @@ -78,15 +78,15 @@ defmodule Bamboo.MandrillAdapterTest do
end

test "deliver/2 sends the to the right url" do
new_email |> MandrillAdapter.deliver(@config)
new_email() |> MandrillAdapter.deliver(@config)

assert_receive {:fake_mandrill, %{request_path: request_path}}

assert request_path == "/api/1.0/messages/send.json"
end

test "deliver/2 sends the to the right url for templates" do
new_email |> MandrillHelper.template("hello") |> MandrillAdapter.deliver(@config)
new_email() |> MandrillHelper.template("hello") |> MandrillAdapter.deliver(@config)

assert_receive {:fake_mandrill, %{request_path: request_path}}

Expand Down Expand Up @@ -133,7 +133,7 @@ defmodule Bamboo.MandrillAdapterTest do
end

test "deliver/2 adds extra params to the message " do
email = new_email |> MandrillHelper.put_param("important", true)
email = new_email() |> MandrillHelper.put_param("important", true)

email |> MandrillAdapter.deliver(@config)

Expand All @@ -142,7 +142,7 @@ defmodule Bamboo.MandrillAdapterTest do
end

test "deliver/2 puts template name and empty content" do
email = new_email |> MandrillHelper.template("hello")
email = new_email() |> MandrillHelper.template("hello")

email |> MandrillAdapter.deliver(@config)

Expand All @@ -152,7 +152,7 @@ defmodule Bamboo.MandrillAdapterTest do
end

test "deliver/2 puts template name and content" do
email = new_email |> MandrillHelper.template("hello", [
email = new_email() |> MandrillHelper.template("hello", [
%{name: 'example name', content: 'example content'}
])

Expand Down
12 changes: 6 additions & 6 deletions test/lib/bamboo/adapters/mandrill_helper_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Bamboo.MandrillHelperTest do
alias Bamboo.MandrillHelper

test "put_param/3 puts a map in private.message_params" do
email = new_email |> MandrillHelper.put_param("track_links", true)
email = new_email() |> MandrillHelper.put_param("track_links", true)

assert email.private.message_params == %{"track_links" => true}
end
Expand All @@ -21,7 +21,7 @@ defmodule Bamboo.MandrillHelperTest do
}
]

email = MandrillHelper.put_merge_vars new_email, users, fn(user) ->
email = MandrillHelper.put_merge_vars new_email(), users, fn(user) ->
%{full_name: user.full_name}
end

Expand Down Expand Up @@ -49,18 +49,18 @@ defmodule Bamboo.MandrillHelperTest do
end

test "adds tags to mandrill emails" do
email = new_email |> MandrillHelper.tag("welcome-email")
email = new_email() |> MandrillHelper.tag("welcome-email")
assert email.private.message_params == %{"tags" => ["welcome-email"]}

email = new_email |> MandrillHelper.tag(["welcome-email", "awesome"])
email = new_email() |> MandrillHelper.tag(["welcome-email", "awesome"])
assert email.private.message_params == %{"tags" => ["welcome-email", "awesome"]}
end

test "adds template information to mandrill emails" do
email = new_email |> MandrillHelper.template("welcome", [%{"name" => "example_name", "content" => "example_content"}])
email = new_email() |> MandrillHelper.template("welcome", [%{"name" => "example_name", "content" => "example_content"}])
assert email.private == %{template_name: "welcome", template_content: [%{"name" => "example_name", "content" => "example_content"}]}

email = new_email |> MandrillHelper.template("welcome")
email = new_email() |> MandrillHelper.template("welcome")
assert email.private == %{template_name: "welcome", template_content: []}
end
end
6 changes: 3 additions & 3 deletions test/lib/bamboo/adapters/sendgrid_adapter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule Bamboo.SendgridAdapterTest do
def start_server(parent) do
Agent.start_link(fn -> HashDict.new end, name: __MODULE__)
Agent.update(__MODULE__, &HashDict.put(&1, :parent, parent))
port = get_free_port
port = get_free_port()
Application.put_env(:bamboo, :sendgrid_base_uri, "http://localhost:#{port}")
Plug.Adapters.Cowboy.http __MODULE__, [], port: port, ref: __MODULE__
end
Expand Down Expand Up @@ -50,7 +50,7 @@ defmodule Bamboo.SendgridAdapterTest do
end

setup do
FakeSendgrid.start_server(self)
FakeSendgrid.start_server(self())

on_exit fn ->
FakeSendgrid.shutdown
Expand All @@ -70,7 +70,7 @@ defmodule Bamboo.SendgridAdapterTest do
end

test "deliver/2 sends the to the right url" do
new_email |> SendgridAdapter.deliver(@config)
new_email() |> SendgridAdapter.deliver(@config)

assert_receive {:fake_sendgrid, %{request_path: request_path}}

Expand Down
2 changes: 1 addition & 1 deletion test/lib/bamboo/adapters/sendgrid_helper_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Bamboo.SendgridHelperTest do
@template_id "80509523-83de-42b6-a2bf-54b7513bd2aa"

setup do
{:ok, email: Bamboo.Email.new_email}
{:ok, email: Bamboo.Email.new_email()}
end

test "with_template/2 adds the correct template", %{email: email} do
Expand Down
Loading

0 comments on commit ec518ec

Please sign in to comment.