77 lines
2.2 KiB
Elixir
77 lines
2.2 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
|
|
|
|
describe "show_in_overview attribute" do
|
|
test "creates custom field with show_in_overview: true" do
|
|
assert {:ok, custom_field} =
|
|
CustomField
|
|
|> Ash.Changeset.for_create(:create, %{
|
|
name: "test_field_show",
|
|
value_type: :string,
|
|
show_in_overview: true
|
|
})
|
|
|> Ash.create()
|
|
|
|
assert custom_field.show_in_overview == true
|
|
end
|
|
|
|
test "creates custom field with show_in_overview: true (default)" do
|
|
assert {:ok, custom_field} =
|
|
CustomField
|
|
|> Ash.Changeset.for_create(:create, %{
|
|
name: "test_field_hide",
|
|
value_type: :string
|
|
})
|
|
|> Ash.create()
|
|
|
|
assert custom_field.show_in_overview == true
|
|
end
|
|
|
|
test "updates show_in_overview to true" do
|
|
{:ok, custom_field} =
|
|
CustomField
|
|
|> Ash.Changeset.for_create(:create, %{
|
|
name: "test_field_update",
|
|
value_type: :string,
|
|
show_in_overview: false
|
|
})
|
|
|> Ash.create()
|
|
|
|
assert {:ok, updated_field} =
|
|
custom_field
|
|
|> Ash.Changeset.for_update(:update, %{show_in_overview: true})
|
|
|> Ash.update()
|
|
|
|
assert updated_field.show_in_overview == true
|
|
end
|
|
|
|
test "updates show_in_overview to false" do
|
|
{:ok, custom_field} =
|
|
CustomField
|
|
|> Ash.Changeset.for_create(:create, %{
|
|
name: "test_field_update2",
|
|
value_type: :string,
|
|
show_in_overview: true
|
|
})
|
|
|> Ash.create()
|
|
|
|
assert {:ok, updated_field} =
|
|
custom_field
|
|
|> Ash.Changeset.for_update(:update, %{show_in_overview: false})
|
|
|> Ash.update()
|
|
|
|
assert updated_field.show_in_overview == false
|
|
end
|
|
end
|
|
end
|