{"action":"created","comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/39936083","id":39936083,"diff_hunk":"@@ -0,0 +1,258 @@\n+require 'test_helper'\n+\n+module ActiveModel\n+  class Serializer\n+    class Adapter\n+      class Json\n+        class NestedAssociationsTest < Minitest::Test\n+          class NestedPostSerializer < ActiveModel::Serializer\n+            attributes :id, :title\n+\n+            has_many :comments, include: :author\n+          end\n+\n+          class NestedCommentBelongsToSerializer < ActiveModel::Serializer\n+            attributes :id, :body\n+\n+            belongs_to :author, include: [:posts]\n+          end\n+\n+          class NestedAuthorSerializer < ActiveModel::Serializer\n+            attributes :id, :name\n+\n+            has_many :posts, include: [:comments]\n+          end\n+\n+          class ComplexNestedAuthorSerializer < ActiveModel::Serializer\n+            attributes :id, :name\n+\n+            # it would normally be silly to have this in production code, cause a post's\n+            # author in this case is always going to be your root object\n+            has_many :posts, include: [:author, comments: [:author]]\n+          end\n+\n+          class MultipleRelationshipAuthorSerializer < ActiveModel::Serializer\n+            attributes :id, :name\n+\n+            has_many :posts, include: [{ comments: [:author] }]","path":"test/adapter/json/nested_associations_test.rb","position":37,"original_position":37,"commit_id":"ddef735bec9c169919b6a04c853b2f4c0892d11a","original_commit_id":"f1b170590936768c64814fe5543f39f0db5ba81c","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"body":"could be in the rubocop_todo.yml","created_at":"2015-09-20T23:02:32Z","updated_at":"2015-09-20T23:02:32Z","html_url":"https://github.com/rails-api/active_model_serializers/pull/1127#discussion_r39936083","pull_request_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127","_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/39936083"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1127#discussion_r39936083"},"pull_request":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127"}}},"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127","id":44369970,"html_url":"https://github.com/rails-api/active_model_serializers/pull/1127","diff_url":"https://github.com/rails-api/active_model_serializers/pull/1127.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/1127.patch","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1127","number":1127,"state":"open","locked":false,"title":"Support nested associations for json and attributes adapters","user":{"login":"NullVoxPopuli","id":199018,"avatar_url":"https://avatars.githubusercontent.com/u/199018?v=3","gravatar_id":"","url":"https://api.github.com/users/NullVoxPopuli","html_url":"https://github.com/NullVoxPopuli","followers_url":"https://api.github.com/users/NullVoxPopuli/followers","following_url":"https://api.github.com/users/NullVoxPopuli/following{/other_user}","gists_url":"https://api.github.com/users/NullVoxPopuli/gists{/gist_id}","starred_url":"https://api.github.com/users/NullVoxPopuli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NullVoxPopuli/subscriptions","organizations_url":"https://api.github.com/users/NullVoxPopuli/orgs","repos_url":"https://api.github.com/users/NullVoxPopuli/repos","events_url":"https://api.github.com/users/NullVoxPopuli/events{/privacy}","received_events_url":"https://api.github.com/users/NullVoxPopuli/received_events","type":"User","site_admin":false},"body":"Originally #1114 (I messed up the history because I merged instead of rebased)\r\n\r\nThis PR is based off of #1111, cause I needed the refactoring.\r\n\r\nDiscussion of idea here: #1113\r\n\r\nRelates to:\r\n#921\r\n#1073\r\n\r\nBasically:\r\n\r\n```ruby\r\nBlogSerializer < #...\r\n  has_many :posts, include: { author: [:bio], comments: [:author]] }\r\nend\r\n```\r\nresulting json may look like:\r\n\r\n```\r\n{\r\n  blog: {\r\n    posts: [\r\n      {\r\n        author: {\r\n          bio: {...}\r\n        },\r\n        comments: [\r\n          {  author: {...} }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\nSee the included tests for more examples.","created_at":"2015-09-07T16:34:52Z","updated_at":"2015-09-20T23:02:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff86cebefaf5fb4404fe09b7e1335465b6633625","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127/commits","review_comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127/comments","review_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1127/comments","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/ddef735bec9c169919b6a04c853b2f4c0892d11a","head":{"label":"NullVoxPopuli:support-nested-associations-for-json-adapter","ref":"support-nested-associations-for-json-adapter","sha":"ddef735bec9c169919b6a04c853b2f4c0892d11a","user":{"login":"NullVoxPopuli","id":199018,"avatar_url":"https://avatars.githubusercontent.com/u/199018?v=3","gravatar_id":"","url":"https://api.github.com/users/NullVoxPopuli","html_url":"https://github.com/NullVoxPopuli","followers_url":"https://api.github.com/users/NullVoxPopuli/followers","following_url":"https://api.github.com/users/NullVoxPopuli/following{/other_user}","gists_url":"https://api.github.com/users/NullVoxPopuli/gists{/gist_id}","starred_url":"https://api.github.com/users/NullVoxPopuli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NullVoxPopuli/subscriptions","organizations_url":"https://api.github.com/users/NullVoxPopuli/orgs","repos_url":"https://api.github.com/users/NullVoxPopuli/repos","events_url":"https://api.github.com/users/NullVoxPopuli/events{/privacy}","received_events_url":"https://api.github.com/users/NullVoxPopuli/received_events","type":"User","site_admin":false},"repo":{"id":25101596,"name":"active_model_serializers","full_name":"NullVoxPopuli/active_model_serializers","owner":{"login":"NullVoxPopuli","id":199018,"avatar_url":"https://avatars.githubusercontent.com/u/199018?v=3","gravatar_id":"","url":"https://api.github.com/users/NullVoxPopuli","html_url":"https://github.com/NullVoxPopuli","followers_url":"https://api.github.com/users/NullVoxPopuli/followers","following_url":"https://api.github.com/users/NullVoxPopuli/following{/other_user}","gists_url":"https://api.github.com/users/NullVoxPopuli/gists{/gist_id}","starred_url":"https://api.github.com/users/NullVoxPopuli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NullVoxPopuli/subscriptions","organizations_url":"https://api.github.com/users/NullVoxPopuli/orgs","repos_url":"https://api.github.com/users/NullVoxPopuli/repos","events_url":"https://api.github.com/users/NullVoxPopuli/events{/privacy}","received_events_url":"https://api.github.com/users/NullVoxPopuli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NullVoxPopuli/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":true,"url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers","forks_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/forks","keys_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/events","assignees_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/merges","archive_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/NullVoxPopuli/active_model_serializers/releases{/id}","created_at":"2014-10-12T00:59:37Z","updated_at":"2014-10-15T23:46:13Z","pushed_at":"2015-09-19T18:35:12Z","git_url":"git://github.com/NullVoxPopuli/active_model_serializers.git","ssh_url":"git@github.com:NullVoxPopuli/active_model_serializers.git","clone_url":"https://github.com/NullVoxPopuli/active_model_serializers.git","svn_url":"https://github.com/NullVoxPopuli/active_model_serializers","homepage":"","size":1877,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"rails-api:master","ref":"master","sha":"7cf0e93d03a05792909ee6e5e95a189a4dd81a2c","user":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"repo":{"id":2889230,"name":"active_model_serializers","full_name":"rails-api/active_model_serializers","owner":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails-api/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":false,"url":"https://api.github.com/repos/rails-api/active_model_serializers","forks_url":"https://api.github.com/repos/rails-api/active_model_serializers/forks","keys_url":"https://api.github.com/repos/rails-api/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails-api/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails-api/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/rails-api/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/events","assignees_url":"https://api.github.com/repos/rails-api/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/rails-api/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/rails-api/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/rails-api/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/rails-api/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails-api/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/rails-api/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails-api/active_model_serializers/merges","archive_url":"https://api.github.com/repos/rails-api/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails-api/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/rails-api/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/rails-api/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/rails-api/active_model_serializers/releases{/id}","created_at":"2011-12-01T06:39:26Z","updated_at":"2015-09-20T17:05:54Z","pushed_at":"2015-09-20T22:57:22Z","git_url":"git://github.com/rails-api/active_model_serializers.git","ssh_url":"git@github.com:rails-api/active_model_serializers.git","clone_url":"https://github.com/rails-api/active_model_serializers.git","svn_url":"https://github.com/rails-api/active_model_serializers","homepage":"","size":6438,"stargazers_count":2982,"watchers_count":2982,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":685,"mirror_url":null,"open_issues_count":162,"forks":685,"open_issues":162,"watchers":2982,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1127"},"issue":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1127"},"comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1127/comments"},"review_comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127/comments"},"review_comment":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1127/commits"},"statuses":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/ddef735bec9c169919b6a04c853b2f4c0892d11a"}}}}