Skip to content

Commit

Permalink
Test phx.gen.auth timestamp_type
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcarvalho committed Apr 28, 2024
1 parent a0bd269 commit bb4a43e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion priv/templates/phx.gen.auth/migration.ex
Expand Up @@ -8,7 +8,7 @@ defmodule <%= inspect schema.repo %>.Migrations.Create<%= Macro.camelize(schema.
<%= if schema.binary_id do %> add :id, :binary_id, primary_key: true
<% end %> <%= migration.column_definitions[:email] %>
add :hashed_password, :string, null: false
add :confirmed_at, <%= schema.timestamp_type %>
add :confirmed_at, <%= inspect schema.timestamp_type %>

timestamps(<%= if schema.timestamp_type != :naive_datetime, do: "type: #{inspect schema.timestamp_type}" %>)
end
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/phx.gen.auth/schema.ex
Expand Up @@ -7,7 +7,7 @@ defmodule <%= inspect schema.module %> do
field :email, :string
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, <%= schema.timestamp_type %>
field :confirmed_at, <%= inspect schema.timestamp_type %>

timestamps(<%= if schema.timestamp_type != :naive_datetime, do: "type: #{inspect schema.timestamp_type}" %>)
end
Expand Down
11 changes: 8 additions & 3 deletions test/mix/tasks/phx.gen.auth_test.exs
Expand Up @@ -950,12 +950,17 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do

assert_file migration, fn file ->
assert file =~ "timestamps(type: :utc_datetime)"
assert file =~ "timestamps(type: :utc_datetime, updated_at: false)"
end


assert_file("lib/my_app/accounts/user.ex", fn file ->
assert_file "lib/my_app/accounts/user.ex", fn file ->
assert file =~ "field :confirmed_at, :utc_datetime"
assert file =~ "timestamps(type: :utc_datetime)"
end)
end

assert_file "lib/my_app/accounts/user_token.ex", fn file ->
assert file =~ "timestamps(type: :utc_datetime, updated_at: false)"
end
end)
end)
end
Expand Down

0 comments on commit bb4a43e

Please sign in to comment.