alphagov/courts-api — pull request #8 by jennyd (2014-12-12 11:55:20+00:00)
Title: Court publishing

This adds a PUT route to allow a very simple court to be published. It's the minimum possible to send enough to the content-store to enable a frontend app to display the name of the court:

- `400` if request body is invalid JSON
- `422` if name or slug aren't present in the request body
- PUT to the publishing API
- include the published URL and the court's name in the response body

This doesn't:
- check the `Content-Type` or `Accept` headers; that'll take a little refactoring of the specs to use a JSON test helper as we [do for HMRC](https://github.com/alphagov/hmrc-manuals-api/blob/master/spec/support/json_request_helpers.rb#L2-L9)
- return the status code from the publishing API
- handle any errors from the publishing API explicitly
- set the `Location` header (which we should do for a `201`)
- use any authentication
- validate anything more than that `name` and `slug` are present in the request

Rails allows [both PATCH and PUT](http://edgeguides.rubyonrails.org/routing.html#crud-verbs-and-actions) for the `update` action; we probably don't want to support PATCH, but that isn't dealt with here.

The last commit (to use single quotes wherever possible) might be controversial, and can be removed if the rest of the team disagrees with me.