@@ -45,7 +45,7 @@ defmodule Test.Acceptance.PatchTest do
45
45
46
46
argument ( :bios , { :array , :map } )
47
47
48
- change manage_relationship ( :bios , type: :append_and_remove )
48
+ change ( manage_relationship ( :bios , type: :append_and_remove ) )
49
49
end
50
50
51
51
update :delete_posts do
@@ -67,7 +67,7 @@ defmodule Test.Acceptance.PatchTest do
67
67
allow_nil? ( false )
68
68
end
69
69
70
- change ( manage_relationship ( :bios , type : :remove ) )
70
+ change ( manage_relationship ( :bios , on_match : :destroy ) )
71
71
end
72
72
end
73
73
@@ -523,53 +523,24 @@ defmodule Test.Acceptance.PatchTest do
523
523
author: author ,
524
524
bios: bios
525
525
} 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
+ )
558
536
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" )
561
542
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 == [ ]
573
544
end
574
545
end
575
546
end
0 commit comments