{"action":"created","issue":{"url":"https://api.github.com/repos/alphagov/whitehall/issues/2431","labels_url":"https://api.github.com/repos/alphagov/whitehall/issues/2431/labels{/name}","comments_url":"https://api.github.com/repos/alphagov/whitehall/issues/2431/comments","events_url":"https://api.github.com/repos/alphagov/whitehall/issues/2431/events","html_url":"https://github.com/alphagov/whitehall/pull/2431","id":127421798,"number":2431,"title":"Test against publisher v2 schema","user":{"login":"boffbowsh","id":18276,"avatar_url":"https://avatars.githubusercontent.com/u/18276?v=3","gravatar_id":"","url":"https://api.github.com/users/boffbowsh","html_url":"https://github.com/boffbowsh","followers_url":"https://api.github.com/users/boffbowsh/followers","following_url":"https://api.github.com/users/boffbowsh/following{/other_user}","gists_url":"https://api.github.com/users/boffbowsh/gists{/gist_id}","starred_url":"https://api.github.com/users/boffbowsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boffbowsh/subscriptions","organizations_url":"https://api.github.com/users/boffbowsh/orgs","repos_url":"https://api.github.com/users/boffbowsh/repos","events_url":"https://api.github.com/users/boffbowsh/events{/privacy}","received_events_url":"https://api.github.com/users/boffbowsh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-19T11:07:49Z","updated_at":"2016-01-20T09:23:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/alphagov/whitehall/pulls/2431","html_url":"https://github.com/alphagov/whitehall/pull/2431","diff_url":"https://github.com/alphagov/whitehall/pull/2431.diff","patch_url":"https://github.com/alphagov/whitehall/pull/2431.patch"},"body":"When Whitehall was ported to use v2 of the Publishing API, it wasn't updated to perform validation against the V2 schemas. This lead to issues where the app was sending documents containing now-invalid properties like `content_id` and `update_type`, and not sending required properties such as `redirects`, `description` and `title`.\r\n\r\nIn order to fix this, it became necessary to refactor the `PublishingApiPresenters` classes and extract common functionality into a base `Item` presenter. These presenters now have an interface of explicit public methods that expose the `content_id`, the document for the `content` API call, the `links` hash and the `update_type`. The locale is still taken from the content document. This replaces the previous `as_json` method.\r\n\r\nThe only production code that has been updated is the presenters and the `PublishingApi*Worker` classes that use them to determine what to send to the Publishing API. However, many tests throughout the codebase needed to be updated to use this new format, because lots of things that pretend to be unit tests really aren't. At some point we should refactor these to have clearer testing boundaries, and stub the calls to `gds-api-adapters` rather than using WebMock. We should trust the pact testing within `gds-api-adapters` to cover what is actually being sent to the Publishing API. We should also be able to test a single type of presenter that conforms to the above interface, and then test each presenter against that interface. But that's for another day.\r\n\r\n/cc @benilovj @jamiecobbett @elliotcm @gpeng "},"comment":{"url":"https://api.github.com/repos/alphagov/whitehall/issues/comments/173142408","html_url":"https://github.com/alphagov/whitehall/pull/2431#issuecomment-173142408","issue_url":"https://api.github.com/repos/alphagov/whitehall/issues/2431","id":173142408,"user":{"login":"elliotcm","id":109225,"avatar_url":"https://avatars.githubusercontent.com/u/109225?v=3","gravatar_id":"","url":"https://api.github.com/users/elliotcm","html_url":"https://github.com/elliotcm","followers_url":"https://api.github.com/users/elliotcm/followers","following_url":"https://api.github.com/users/elliotcm/following{/other_user}","gists_url":"https://api.github.com/users/elliotcm/gists{/gist_id}","starred_url":"https://api.github.com/users/elliotcm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elliotcm/subscriptions","organizations_url":"https://api.github.com/users/elliotcm/orgs","repos_url":"https://api.github.com/users/elliotcm/repos","events_url":"https://api.github.com/users/elliotcm/events{/privacy}","received_events_url":"https://api.github.com/users/elliotcm/received_events","type":"User","site_admin":false},"created_at":"2016-01-20T09:23:30Z","updated_at":"2016-01-20T09:23:30Z","body":"To follow up on @tommyp's comment, the intent here is that different publishing applications might ask for the update type and change note at different times.  Some might treat it as part of the editing process, others as part of the publishing process.\r\n\r\nAs such, publishing API will accept `update_type` with optional `change_note` BOTH during save AND during publish, with the publish contents taking preference if both have been provided.\r\n\r\nThis will also make change note optional in all cases as far as the API is concerned.  Restrictions like \"major changes need a change note\" should be handled in the publishing applications."}}