Add actor parameter to all tests requiring authorization
All checks were successful
continuous-integration/drone/push Build is passing

This commit adds actor: system_actor to all Ash operations in tests that
require authorization.
This commit is contained in:
Moritz 2026-01-23 20:00:24 +01:00
parent 4c846f8bba
commit a6cdeaa18d
Signed by: moritz
GPG key ID: 1020A035E5DD0824
75 changed files with 4649 additions and 2865 deletions

View file

@ -101,7 +101,8 @@ defmodule Mv.Membership.Import.MemberCSVTest do
assert chunk_result.errors == []
# Verify member was created
members = Mv.Membership.list_members!()
system_actor = Mv.Helpers.SystemActor.get_system_actor()
members = Mv.Membership.list_members!(actor: system_actor)
assert Enum.any?(members, &(&1.email == "john@example.com"))
end
@ -174,8 +175,12 @@ defmodule Mv.Membership.Import.MemberCSVTest do
test "returns error for duplicate email" do
# Create existing member first
system_actor = Mv.Helpers.SystemActor.get_system_actor()
{:ok, _existing} =
Mv.Membership.create_member(%{email: "duplicate@example.com", first_name: "Existing"})
Mv.Membership.create_member(%{email: "duplicate@example.com", first_name: "Existing"},
actor: system_actor
)
chunk_rows_with_lines = [
{2, %{member: %{email: "duplicate@example.com", first_name: "New"}, custom: %{}}}
@ -199,6 +204,8 @@ defmodule Mv.Membership.Import.MemberCSVTest do
end
test "creates member with custom field values" do
system_actor = Mv.Helpers.SystemActor.get_system_actor()
# Create custom field first
{:ok, custom_field} =
Mv.Membership.CustomField
@ -206,7 +213,7 @@ defmodule Mv.Membership.Import.MemberCSVTest do
name: "Phone",
value_type: :string
})
|> Ash.create()
|> Ash.create(actor: system_actor)
chunk_rows_with_lines = [
{2,
@ -232,7 +239,8 @@ defmodule Mv.Membership.Import.MemberCSVTest do
assert chunk_result.failed == 0
# Verify member and custom field value were created
members = Mv.Membership.list_members!()
system_actor = Mv.Helpers.SystemActor.get_system_actor()
members = Mv.Membership.list_members!(actor: system_actor)
member = Enum.find(members, &(&1.email == "withcustom@example.com"))
assert member != nil