Skip to content

Commit b0e3054

Browse files
committed
configure proxy_endpoint pubsub_server
1 parent 6b31e81 commit b0e3054

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

lib/mix/tasks/beacon.gen.proxy_endpoint.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule Mix.Tasks.Beacon.Gen.ProxyEndpoint.Docs do
2222
## Options
2323
2424
* `--secret-key-base` (optional) - The value to use for secret_key_base in your app config.
25-
By default, Beacon will generate a new value and update all existing config to match that value.
25+
By default, Beacon will generate a new value and update all existing config to match that value.
2626
If you don't want this behavior, copy the secret_key_base from your app config and provide it here.
2727
* `--signing-salt` (optional) - The value to use for signing_salt in your app config.
2828
By default, Beacon will generate a new value and update all existing config to match that value.
@@ -154,6 +154,8 @@ if Code.ensure_loaded?(Igniter) do
154154
end
155155

156156
defp configure_proxy_endpoint(igniter, otp_app, proxy_endpoint_module_name) do
157+
pubsub = Igniter.Project.Module.module_name(igniter, "PubSub")
158+
157159
igniter
158160
|> Igniter.update_elixir_file("config/config.exs", fn zipper ->
159161
{:ok,
@@ -163,7 +165,11 @@ if Code.ensure_loaded?(Igniter) do
163165
[proxy_endpoint_module_name],
164166
otp_app,
165167
Sourceror.parse_string!("""
166-
[adapter: Bandit.PhoenixAdapter, live_view: [signing_salt: signing_salt]]
168+
[
169+
adapter: Bandit.PhoenixAdapter,
170+
pubsub_server: #{inspect(pubsub)},
171+
live_view: [signing_salt: signing_salt]
172+
]
167173
""")
168174
)}
169175
end)

test/mix/tasks/gen_proxy_endpoint_test.exs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,28 @@ defmodule Mix.Tasks.Beacon.GenProxyEndpointTest do
7272
""")
7373
# add proxy endpoint config
7474
|> assert_has_patch("config/config.exs", """
75-
12 + |config :test, TestWeb.ProxyEndpoint, adapter: Bandit.PhoenixAdapter, live_view: [signing_salt: signing_salt]
76-
13 + |
75+
10 12 |config :test,
76+
13 + | TestWeb.ProxyEndpoint,
77+
14 + | adapter: Bandit.PhoenixAdapter,
78+
15 + | pubsub_server: Test.PubSub,
79+
16 + | live_view: [signing_salt: signing_salt]
7780
""")
7881
# add session options config
7982
|> assert_has_patch("config/config.exs", """
80-
10 14 |config :test,
81-
11 15 | ecto_repos: [Test.Repo],
82-
12 - | generators: [timestamp_type: :utc_datetime]
83-
16 + | generators: [timestamp_type: :utc_datetime],
84-
17 + | session_options: [
85-
18 + | store: :cookie,
86-
19 + | key: "_test_key",
87-
20 + | signing_salt: signing_salt,
88-
21 + | same_site: "Lax"
89-
22 + | ]
83+
18 + |config :test,
84+
11 19 | ecto_repos: [Test.Repo],
85+
12 - | generators: [timestamp_type: :utc_datetime]
86+
20 + | generators: [timestamp_type: :utc_datetime],
87+
21 + | session_options: [
88+
22 + | store: :cookie,
89+
23 + | key: "_test_key",
90+
24 + | signing_salt: signing_salt,
91+
25 + | same_site: "Lax"
92+
26 + | ]
9093
""")
9194
# update fallback endpoint signing salt
9295
|> assert_has_patch("config/config.exs", """
93-
33 + | live_view: [signing_salt: signing_salt]
96+
37 + | live_view: [signing_salt: signing_salt]
9497
""")
9598
end
9699

0 commit comments

Comments
 (0)