mitgliederverwaltung/test/membership/custom_field_show_in_overview_test.exs
Moritz 0f48a9b15a
Add actor parameter to all tests requiring authorization
This commit adds actor: system_actor to all Ash operations in tests that
require authorization.
2026-01-24 02:21:02 +01:00

82 lines
2.5 KiB
Elixir

defmodule Mv.Membership.CustomFieldShowInOverviewTest do
@moduledoc """
Tests for CustomField show_in_overview attribute.
Tests cover:
- Creating custom fields with show_in_overview: true
- Creating custom fields with show_in_overview: false (default)
- Updating show_in_overview to true
- Updating show_in_overview to false
"""
use Mv.DataCase, async: true
alias Mv.Membership.CustomField
setup do
system_actor = Mv.Helpers.SystemActor.get_system_actor()
%{actor: system_actor}
end
describe "show_in_overview attribute" do
test "creates custom field with show_in_overview: true", %{actor: actor} do
assert {:ok, custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "test_field_show",
value_type: :string,
show_in_overview: true
})
|> Ash.create(actor: actor)
assert custom_field.show_in_overview == true
end
test "creates custom field with show_in_overview: true (default)", %{actor: actor} do
assert {:ok, custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "test_field_hide",
value_type: :string
})
|> Ash.create(actor: actor)
assert custom_field.show_in_overview == true
end
test "updates show_in_overview to true", %{actor: actor} do
{:ok, custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "test_field_update",
value_type: :string,
show_in_overview: false
})
|> Ash.create(actor: actor)
assert {:ok, updated_field} =
custom_field
|> Ash.Changeset.for_update(:update, %{show_in_overview: true})
|> Ash.update(actor: actor)
assert updated_field.show_in_overview == true
end
test "updates show_in_overview to false", %{actor: actor} do
{:ok, custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "test_field_update2",
value_type: :string,
show_in_overview: true
})
|> Ash.create(actor: actor)
assert {:ok, updated_field} =
custom_field
|> Ash.Changeset.for_update(:update, %{show_in_overview: false})
|> Ash.update(actor: actor)
assert updated_field.show_in_overview == false
end
end
end