diff --git a/config/config.exs b/config/config.exs index e1ab7f1..b937f88 100644 --- a/config/config.exs +++ b/config/config.exs @@ -58,8 +58,6 @@ config :logger, :console, # Use Jason for JSON parsing in Phoenix config :phoenix, :json_library, Jason -config :live_beats, :presence_client, LiveBeats.PresenceClient - # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{config_env()}.exs" diff --git a/config/test.exs b/config/test.exs index 63469dc..043e354 100644 --- a/config/test.exs +++ b/config/test.exs @@ -31,5 +31,3 @@ config :logger, level: :warn # Initialize plugs at runtime for faster test compilation config :phoenix, :plug_init_mode, :runtime - -config :live_beats, :presence_client, Phoenix.Presence.Client.Mock diff --git a/lib/live_beats/application.ex b/lib/live_beats/application.ex index 067f171..bdd0725 100644 --- a/lib/live_beats/application.ex +++ b/lib/live_beats/application.ex @@ -23,8 +23,8 @@ defmodule LiveBeats.Application do LiveBeatsWeb.Endpoint, # Start a worker by calling: LiveBeats.Worker.start_link(arg) # {LiveBeats.Worker, arg} - {Phoenix.Presence.Client, client: Application.get_env(:live_beats, :presence_client), pubsub: LiveBeats.PubSub, presence: LiveBeatsWeb.Presence} - ] + + ] ++ start_presence_client(Mix.env) # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options @@ -39,4 +39,10 @@ defmodule LiveBeats.Application do LiveBeatsWeb.Endpoint.config_change(changed, removed) :ok end + + defp start_presence_client(:test), do: [] + + defp start_presence_client(_) do + [{Phoenix.Presence.Client, client: LiveBeats.PresenceClient, pubsub: LiveBeats.PubSub, presence: LiveBeatsWeb.Presence, name: PresenceClient}] + end end