test: added failing test (#40)

This commit is contained in:
kernel-io 2022-05-18 02:39:46 +12:00 committed by GitHub
parent 12b27461b6
commit a861dbf3b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -1160,6 +1160,16 @@ defmodule AshPhoenix.FormTest do
assert is_nil(Map.get(params, "author", "shouldn't exist")) assert is_nil(Map.get(params, "author", "shouldn't exist"))
end end
test "when add_forming a required argument, the added form should be valid without needing to manually validate it" do
form =
Post
|> Form.for_create(:create_author_required, api: Api, forms: [auto?: true])
|> Form.validate(%{"text" => "foo"})
|> Form.add_form([:author], params: %{"email" => "james@foo.com"})
assert form.valid? == true
end
end end
describe "issue #259" do describe "issue #259" do

View file

@ -25,6 +25,11 @@ defmodule AshPhoenix.Test.Post do
change(manage_relationship(:author, type: :direct_control, on_missing: :unrelate)) change(manage_relationship(:author, type: :direct_control, on_missing: :unrelate))
end end
create :create_author_required do
argument(:author, :map, allow_nil?: false)
change(manage_relationship(:author, type: :direct_control, on_missing: :unrelate))
end
update :update_with_replace do update :update_with_replace do
argument(:comments, {:array, :map}) argument(:comments, {:array, :map})
change(manage_relationship(:comments, type: :replace)) change(manage_relationship(:comments, type: :replace))