{"action":"created","comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/36311832","id":36311832,"diff_hunk":"@@ -0,0 +1,154 @@\n+require 'test_helper'\n+\n+module ActiveModel\n+  class Serializer\n+    class Adapter\n+      class JsonApi\n+        class ErrorsTest < Minitest::Test\n+\n+          # see\n+          # https://github.com/rails/rails/blob/4-2-stable/activemodel/lib/active_model/errors.rb\n+          # The below allows you to do:\n+          #\n+          #   model = ModelWithErrors.new\n+          #   model.validate!            # => [\"cannot be nil\"]\n+          #   model.errors.full_messages # => [\"name cannot be nil\"]\n+          class ModelWithErrors\n+            # Required dependency for ActiveModel::Errors\n+            extend ActiveModel::Naming\n+            def initialize\n+              @errors = ActiveModel::Errors.new(self)\n+            end\n+            attr_accessor :name\n+            attr_reader   :errors\n+\n+            # The following methods are needed to be minimally implemented\n+\n+            def read_attribute_for_validation(attr)\n+              send(attr)\n+            end\n+\n+            def self.human_attribute_name(attr, options = {})\n+              attr\n+            end\n+\n+            def self.lookup_ancestors\n+              [self]\n+            end\n+          end\n+\n+          def setup\n+            @model = ModelWithErrors.new\n+          end\n+\n+          class JsonApiErrorSerializer < ActiveModel::Serializer\n+            attribute :source\n+            attribute :detail\n+\n+            def source\n+              {pointer: \"data/attributes/#{object.first}\"}\n+            end\n+\n+            def detail\n+              detail = object.last\n+              if detail.respond_to?(:join)","path":"test/adapter/json_api/errors_test.rb","position":54,"original_position":54,"commit_id":"178dd56cafb8a64f7da868c99356c72b6c8a247b","original_commit_id":"178dd56cafb8a64f7da868c99356c72b6c8a247b","user":{"login":"bbuchalter","id":540762,"avatar_url":"https://avatars.githubusercontent.com/u/540762?v=3","gravatar_id":"","url":"https://api.github.com/users/bbuchalter","html_url":"https://github.com/bbuchalter","followers_url":"https://api.github.com/users/bbuchalter/followers","following_url":"https://api.github.com/users/bbuchalter/following{/other_user}","gists_url":"https://api.github.com/users/bbuchalter/gists{/gist_id}","starred_url":"https://api.github.com/users/bbuchalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbuchalter/subscriptions","organizations_url":"https://api.github.com/users/bbuchalter/orgs","repos_url":"https://api.github.com/users/bbuchalter/repos","events_url":"https://api.github.com/users/bbuchalter/events{/privacy}","received_events_url":"https://api.github.com/users/bbuchalter/received_events","type":"User","site_admin":false},"body":"Forgive me if this is obvious, but I don't see this path of execution under test and I'm not sure why it's required. Could you share your thinking?","created_at":"2015-08-05T15:02:14Z","updated_at":"2015-08-05T15:02:14Z","html_url":"https://github.com/rails-api/active_model_serializers/pull/1004#discussion_r36311832","pull_request_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004","_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/36311832"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1004#discussion_r36311832"},"pull_request":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004"}}},"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004","id":39882907,"html_url":"https://github.com/rails-api/active_model_serializers/pull/1004","diff_url":"https://github.com/rails-api/active_model_serializers/pull/1004.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/1004.patch","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004","number":1004,"state":"open","locked":false,"title":"RFC: Json Api Errors (WIP)","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":"For discussion of how serializing errors is different from resources\r\n\r\n- may often be an instance of ActiveModel::Error\r\n  - which we'd want to call 'messages' on\r\n  - if not, should we expect a hash? or give the end-user an object they must use?\r\n- is necessarily a collection of error objects, each with it's own 'source' and 'detail'\r\n  - it's not quite right to use an ArraySerializer\r\n\r\nImplemented:\r\n\r\n- [x] error root key to collection of error objects\r\n  - [ ] The members data and errors MUST NOT coexist in the same document.\r\n- [x] error objects from ActiveModel::Error\r\n- [ ] id: a unique identifier for this particular occurrence of the problem.\r\n- [ ] links: a links object containing the following members:\r\n  - [ ] about: a link that leads to further details about this particular occurrence of the problem.\r\n- [ ] status: the HTTP status code applicable to this problem, expressed as a string value.\r\n- [ ] code: an application-specific error code, expressed as a string value.\r\n- [ ] title: a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.\r\n- [x] detail: a human-readable explanation specific to this occurrence of the problem.\r\n- [ ] source: an object containing references to the source of the error, optionally including any of the following members:\r\n  -  [ ] pointer: a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) to the associated entity in the request document [e.g. \"/data\" for a primary data object, or \"/data/attributes/title\" for a specific attribute].\r\n  -  [ ] parameter: a string indicating which query parameter caused the error.\r\n- [ ] meta: a meta object containing non-standard meta-information about the error.\r\n\r\nI included relevant json-api details in the PR as comment for convenience, but will remove most as this PR matures.\r\n\r\nref: \r\n- ams issue: https://github.com/rails-api/active_model_serializers/issues/933\r\n- other implementations\r\n  - https://github.com/cerebris/jsonapi-resources/blob/42a3c6409964a0f91544813e9a0437d248832ef4/lib/jsonapi/exceptions.rb","created_at":"2015-07-14T05:29:57Z","updated_at":"2015-08-05T15:02:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4628a654a22e18a4d714c46bf6e9eb288469c803","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004/commits","review_comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004/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/1004/comments","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/178dd56cafb8a64f7da868c99356c72b6c8a247b","head":{"label":"bf4:json_api_errors","ref":"json_api_errors","sha":"178dd56cafb8a64f7da868c99356c72b6c8a247b","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},"repo":{"id":31333715,"name":"active_model_serializers","full_name":"bf4/active_model_serializers","owner":{"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},"private":false,"html_url":"https://github.com/bf4/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":true,"url":"https://api.github.com/repos/bf4/active_model_serializers","forks_url":"https://api.github.com/repos/bf4/active_model_serializers/forks","keys_url":"https://api.github.com/repos/bf4/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bf4/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bf4/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/bf4/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/bf4/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/bf4/active_model_serializers/events","assignees_url":"https://api.github.com/repos/bf4/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/bf4/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/bf4/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/bf4/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bf4/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bf4/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/bf4/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bf4/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/bf4/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/bf4/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/bf4/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/bf4/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/bf4/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/bf4/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/bf4/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/bf4/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/bf4/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/bf4/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/bf4/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bf4/active_model_serializers/merges","archive_url":"https://api.github.com/repos/bf4/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bf4/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/bf4/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/bf4/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/bf4/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/bf4/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bf4/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/bf4/active_model_serializers/releases{/id}","created_at":"2015-02-25T20:15:49Z","updated_at":"2015-02-25T20:15:50Z","pushed_at":"2015-07-31T21:15:58Z","git_url":"git://github.com/bf4/active_model_serializers.git","ssh_url":"git@github.com:bf4/active_model_serializers.git","clone_url":"https://github.com/bf4/active_model_serializers.git","svn_url":"https://github.com/bf4/active_model_serializers","homepage":"","size":1578,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails-api:master","ref":"master","sha":"954e4c51fe6ff4ebbca1692045b3decf3cc1633d","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-08-05T13:52:55Z","pushed_at":"2015-08-04T20:36:45Z","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":5571,"stargazers_count":2876,"watchers_count":2876,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":653,"mirror_url":null,"open_issues_count":140,"forks":653,"open_issues":140,"watchers":2876,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1004"},"issue":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004"},"comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004/comments"},"review_comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004/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/1004/commits"},"statuses":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/178dd56cafb8a64f7da868c99356c72b6c8a247b"}}}}