diff --git a/test/support/generators.ex b/test/support/generators.ex index b04b913..12b2514 100644 --- a/test/support/generators.ex +++ b/test/support/generators.ex @@ -3,6 +3,7 @@ defmodule DecentralisedBookIndex.Generators do use Ash.Generator alias DecentralisedBookIndex.Metadata + alias DecentralisedBookIndex.Accounts @doc """ Generates user changesets with the `:register_with_password` action. @@ -19,6 +20,10 @@ defmodule DecentralisedBookIndex.Generators do password_confirmation: "password" ], overrides: opts, + after_action: fn user -> + role = opts[:role] || :user + Accounts.User.set_role!(user, role, authorize?: false) + end, authorize?: false ) end