feat(custom-field): add join_description attribute for GDPR join-form labels
This commit is contained in:
parent
d51dcb1ac3
commit
b6c2cf58b1
4 changed files with 242 additions and 3 deletions
|
|
@ -159,6 +159,61 @@ defmodule Mv.Membership.CustomFieldValidationTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "join_description" do
|
||||
test "persists join_description when set", %{actor: actor} do
|
||||
assert {:ok, custom_field} =
|
||||
CustomField
|
||||
|> Ash.Changeset.for_create(:create, %{
|
||||
name: "dsgvo_field",
|
||||
value_type: :boolean,
|
||||
join_description: "hereby I confirm the GDPR"
|
||||
})
|
||||
|> Ash.create(actor: actor)
|
||||
|
||||
assert custom_field.join_description == "hereby I confirm the GDPR"
|
||||
end
|
||||
|
||||
test "defaults to nil when not given", %{actor: actor} do
|
||||
assert {:ok, custom_field} =
|
||||
CustomField
|
||||
|> Ash.Changeset.for_create(:create, %{
|
||||
name: "no_join_desc",
|
||||
value_type: :boolean
|
||||
})
|
||||
|> Ash.create(actor: actor)
|
||||
|
||||
assert custom_field.join_description == nil
|
||||
end
|
||||
|
||||
test "rejects join_description longer than 1000 characters", %{actor: actor} do
|
||||
assert {:error, changeset} =
|
||||
CustomField
|
||||
|> Ash.Changeset.for_create(:create, %{
|
||||
name: "too_long_join_desc",
|
||||
value_type: :boolean,
|
||||
join_description: String.duplicate("a", 1001)
|
||||
})
|
||||
|> Ash.create(actor: actor)
|
||||
|
||||
assert [%{field: :join_description, message: message}] = changeset.errors
|
||||
assert message =~ "max" or message =~ "length" or message =~ "1000"
|
||||
end
|
||||
|
||||
test "is writable via the update action", %{actor: actor} do
|
||||
{:ok, custom_field} =
|
||||
CustomField
|
||||
|> Ash.Changeset.for_create(:create, %{name: "updatable", value_type: :boolean})
|
||||
|> Ash.create(actor: actor)
|
||||
|
||||
assert {:ok, updated} =
|
||||
custom_field
|
||||
|> Ash.Changeset.for_update(:update, %{join_description: "Accept the GDPR"})
|
||||
|> Ash.update(actor: actor)
|
||||
|
||||
assert updated.join_description == "Accept the GDPR"
|
||||
end
|
||||
end
|
||||
|
||||
describe "name uniqueness" do
|
||||
test "rejects duplicate names", %{actor: actor} do
|
||||
assert {:ok, _} =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue