fix: change creation of admin user
This commit is contained in:
parent
584442076e
commit
bc4bcd0089
3 changed files with 69 additions and 20 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue