fix: change creation of admin user

This commit is contained in:
Simon 2026-01-19 13:40:28 +01:00
parent 584442076e
commit bc4bcd0089
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
3 changed files with 69 additions and 20 deletions

View file

@ -73,6 +73,26 @@ defmodule Mv.Membership.MemberTest do
end
end
describe "Authorization" do
@valid_attrs %{
first_name: "John",
last_name: "Doe",
email: "john@example.com"
}
test "user without role cannot create member" do
# Create a user without a role
user = Mv.Fixtures.user_fixture()
# Ensure user has no role (nil role)
user_without_role = %{user | role: nil}
# Attempt to create a member with user without role as actor
# This should fail with Ash.Error.Forbidden containing a Policy error
assert {:error, %Ash.Error.Forbidden{errors: [%Ash.Error.Forbidden.Policy{}]}} =
Membership.create_member(@valid_attrs, actor: user_without_role)
end
end
# Helper function for error evaluation
defp error_message(errors, field) do
errors