Skip to content

Commit 5884165

Browse files
committed
chore: fix tests
1 parent 93d7e39 commit 5884165

File tree

1 file changed

+18
-47
lines changed

1 file changed

+18
-47
lines changed

test/acceptance/patch_test.exs

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule Test.Acceptance.PatchTest do
4545

4646
argument(:bios, {:array, :map})
4747

48-
change manage_relationship(:bios, type: :append_and_remove)
48+
change(manage_relationship(:bios, type: :append_and_remove))
4949
end
5050

5151
update :delete_posts do
@@ -67,7 +67,7 @@ defmodule Test.Acceptance.PatchTest do
6767
allow_nil?(false)
6868
end
6969

70-
change(manage_relationship(:bios, type: :remove))
70+
change(manage_relationship(:bios, on_match: :destroy))
7171
end
7272
end
7373

@@ -523,53 +523,24 @@ defmodule Test.Acceptance.PatchTest do
523523
author: author,
524524
bios: bios
525525
} do
526-
assert %{status: 200} =
527-
Domain
528-
|> patch("/authors/#{author.id}/bios/delete", %{
529-
data: %{
530-
attributes: %{bios: Enum.map(bios, &%{author_id: author.id, pkey_b: &1.pkey_b})}
531-
}
532-
})
533-
534-
# related =
535-
# Domain
536-
# |> get("/authors/#{author.id}/bios", status: 200)
537-
# |> Map.get(:resp_body)
538-
# |> Map.get("data")
539-
540-
# refute related
541-
end
542-
end
543-
544-
describe "patch updating bios" do
545-
setup do
546-
author =
547-
Author
548-
|> Ash.Changeset.for_create(:create, %{id: Ecto.UUID.generate(), name: "John"})
549-
|> Ash.create!()
550-
551-
bios =
552-
Enum.map(1..2, fn i ->
553-
Bio
554-
|> Ash.Changeset.for_create(:create, %{author_id: author.id, pkey_b: "b#{i}"})
555-
|> Ash.Changeset.force_change_attribute(:author_id, author.id)
556-
|> Ash.create!()
557-
end)
526+
Domain
527+
|> patch(
528+
"/authors/#{author.id}/bios/delete",
529+
%{
530+
data: %{
531+
attributes: %{bios: Enum.map(bios, &%{author_id: author.id, pkey_b: &1.pkey_b})}
532+
}
533+
},
534+
status: 200
535+
)
558536

559-
%{bios: bios, author: author}
560-
end
537+
related =
538+
Domain
539+
|> get("/authors/#{author.id}/bios", status: 200)
540+
|> Map.get(:resp_body)
541+
|> Map.get("data")
561542

562-
test "patch to update relationship with composite primary key", %{
563-
author: author,
564-
bios: bios
565-
} do
566-
assert %{status: 200} =
567-
Domain
568-
|> patch("/authors/#{author.id}/relationships/bios", %{
569-
data: [
570-
%{type: "bio", author_id: author.id, pkey_b: "b1", bio: "new bio"}
571-
]
572-
})
543+
assert related == []
573544
end
574545
end
575546
end

0 commit comments

Comments
 (0)