test: add tdd tests for groups administration #372
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
0a2aa3bad0
commit
f05fae3ea3
6 changed files with 962 additions and 4 deletions
|
|
@ -262,4 +262,39 @@ defmodule Mv.Fixtures do
|
|||
{:error, error} -> raise "Failed to create member: #{inspect(error)}"
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Creates a group with default or custom attributes.
|
||||
|
||||
Uses system_actor for authorization to bypass permission checks in tests.
|
||||
|
||||
## Parameters
|
||||
- `attrs` - Map or keyword list of attributes to override defaults
|
||||
|
||||
## Returns
|
||||
- Group struct
|
||||
|
||||
## Examples
|
||||
|
||||
iex> group_fixture()
|
||||
%Mv.Membership.Group{name: "Test Group", slug: "test-group", ...}
|
||||
|
||||
iex> group_fixture(%{name: "Board Members", description: "Board members group"})
|
||||
%Mv.Membership.Group{name: "Board Members", slug: "board-members", ...}
|
||||
|
||||
"""
|
||||
def group_fixture(attrs \\ %{}) do
|
||||
system_actor = Mv.Helpers.SystemActor.get_system_actor()
|
||||
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
name: "Test Group #{System.unique_integer([:positive])}",
|
||||
description: "Test description"
|
||||
})
|
||||
|> Mv.Membership.create_group(actor: system_actor)
|
||||
|> case do
|
||||
{:ok, group} -> group
|
||||
{:error, error} -> raise "Failed to create group: #{inspect(error)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue