Skip to content
Merged
Changes from all commits
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
23 changes: 22 additions & 1 deletion test/mix/tasks/phx.gen.auth_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do
test "allows templates to be overridden", config do
in_tmp_phx_project(config.test, fn ->
File.mkdir_p!("priv/templates/phx.gen.auth")
File.write!("priv/templates/phx.gen.auth/auth.ex", "#it works!")
File.write!("priv/templates/phx.gen.auth/auth.ex.eex", "#it works!")

send(self(), {:mix_shell_input, :yes?, false})

Expand All @@ -1459,6 +1459,27 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do
end)
end

test "allows templates to be overridden (backwards compatibility)", config do
in_tmp_phx_project(config.test, fn ->
File.mkdir_p!("priv/templates/phx.gen.auth")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually thinking we could make the backward compatibility check generic. Not specific to phx.gen.auth.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I don’t really care where it is, as long as there’s a check for it somewhere

# verify that projects using the old filenames without .eex extension still work
File.write!("priv/templates/phx.gen.auth/auth.ex", "#it works with compat!")

send(self(), {:mix_shell_input, :yes?, false})

Gen.Auth.run(
~w(Accounts Admin admins --no-compile),
ecto_adapter: Ecto.Adapters.Postgres
)

assert_received {:mix_shell, :yes?, [@liveview_option_message]}

assert_file("lib/my_app_web/admin_auth.ex", fn file ->
assert file =~ ~S|it works with compat!|
end)
end)
end

test "with --no-agents-md does not inject content to AGENTS.md", config do
in_tmp_phx_project(config.test, fn ->
send(self(), {:mix_shell_input, :yes?, false})
Expand Down