@@ -562,207 +562,6 @@ def test_serializer_include_sub_objects
562562 )
563563 end
564564
565- def test_serializer_include_has_many_sub_objects_only
566-
567- assert_hash_equals (
568- {
569- data : {
570- type : 'posts' ,
571- id : '1' ,
572- attributes : {
573- title : 'New post' ,
574- body : 'A body!!!' ,
575- subject : 'New post'
576- } ,
577- links : {
578- self : '/posts/1'
579- } ,
580- relationships : {
581- section : {
582- links : {
583- self : '/posts/1/relationships/section' ,
584- related : '/posts/1/section'
585- } ,
586- data : nil
587- } ,
588- author : {
589- links : {
590- self : '/posts/1/relationships/author' ,
591- related : '/posts/1/author'
592- } ,
593- data : {
594- type : 'people' ,
595- id : '1'
596- }
597- } ,
598- tags : {
599- links : {
600- self : '/posts/1/relationships/tags' ,
601- related : '/posts/1/tags'
602- }
603- } ,
604- comments : {
605- links : {
606- self : '/posts/1/relationships/comments' ,
607- related : '/posts/1/comments'
608- }
609- }
610- }
611- } ,
612- included : [
613- {
614- type : 'tags' ,
615- id : '1' ,
616- attributes : {
617- name : 'short'
618- } ,
619- links : {
620- self : '/tags/1'
621- } ,
622- relationships : {
623- posts : {
624- links : {
625- self : '/tags/1/relationships/posts' ,
626- related : '/tags/1/posts'
627- }
628- }
629- }
630- } ,
631- {
632- type : 'tags' ,
633- id : '2' ,
634- attributes : {
635- name : 'whiny'
636- } ,
637- links : {
638- self : '/tags/2'
639- } ,
640- relationships : {
641- posts : {
642- links : {
643- self : '/tags/2/relationships/posts' ,
644- related : '/tags/2/posts'
645- }
646- }
647- }
648- } ,
649- {
650- type : 'tags' ,
651- id : '4' ,
652- attributes : {
653- name : 'happy'
654- } ,
655- links : {
656- self : '/tags/4'
657- } ,
658- relationships : {
659- posts : {
660- links : {
661- self : '/tags/4/relationships/posts' ,
662- related : '/tags/4/posts'
663- }
664- }
665- }
666- }
667- ]
668- } ,
669- JSONAPI ::ResourceSerializer . new ( PostResource , include : [ 'comments.tags' ] ) . serialize_to_hash ( PostResource . new ( @post ) )
670- )
671- end
672-
673- def test_serializer_include_has_one_sub_objects_only
674-
675- assert_hash_equals (
676- {
677- data : {
678- type : 'posts' ,
679- id : '1' ,
680- attributes : {
681- title : 'New post' ,
682- body : 'A body!!!' ,
683- subject : 'New post'
684- } ,
685- links : {
686- self : '/posts/1'
687- } ,
688- relationships : {
689- section : {
690- links : {
691- self : '/posts/1/relationships/section' ,
692- related : '/posts/1/section'
693- } ,
694- data : nil
695- } ,
696- author : {
697- links : {
698- self : '/posts/1/relationships/author' ,
699- related : '/posts/1/author'
700- } ,
701- data : {
702- type : 'people' ,
703- id : '1'
704- }
705- } ,
706- tags : {
707- links : {
708- self : '/posts/1/relationships/tags' ,
709- related : '/posts/1/tags'
710- }
711- } ,
712- comments : {
713- links : {
714- self : '/posts/1/relationships/comments' ,
715- related : '/posts/1/comments'
716- }
717- }
718- }
719- } ,
720- included : [
721- {
722- type : 'comments' ,
723- id : '1' ,
724- attributes : {
725- body : 'what a dumb post'
726- } ,
727- links : {
728- self : '/comments/1'
729- } ,
730- relationships : {
731- author : {
732- links : {
733- self : '/comments/1/relationships/author' ,
734- related : '/comments/1/author'
735- } ,
736- data : {
737- type : 'people' ,
738- id : '1'
739- }
740- } ,
741- post : {
742- links : {
743- self : '/comments/1/relationships/post' ,
744- related : '/comments/1/post'
745- } ,
746- data : {
747- type : 'posts' ,
748- id : '1'
749- }
750- } ,
751- tags : {
752- links : {
753- self : '/comments/1/relationships/tags' ,
754- related : '/comments/1/tags'
755- }
756- }
757- }
758- }
759- ]
760- } ,
761- JSONAPI ::ResourceSerializer . new ( PostResource ,
762- include : [ 'author.comments' ] ) . serialize_to_hash ( PostResource . new ( @post ) )
763- )
764- end
765-
766565 def test_serializer_different_foreign_key
767566 serialized = JSONAPI ::ResourceSerializer . new (
768567 PersonResource ,
0 commit comments