ushahidi/Lamu — pull request #22 by rjmackay (2013-03-20 01:50:22+00:00)
Title: Posts API work

This was intended to be mostly posts work but expanded a bit as I added further tests and refined the REST api behaviour. Sorry for the giant pull request - will keep them smaller in future.

Api Changes
* Throw 400/404 responses where-ever needed. No more 200 OK but error in json
* Update API responses to include both url and id of relations
* Validation rules in Group model
* check group exists when updating Attribute
* Posts API GET/PUT/POST/DELETE implemented
* including limit/offset params
* including order/orderby params
* including saving tags
*

Tests added/modified:
* Create/Update/Delete Post
* Create invalid post (missing fields)
* List all/one post
* Test for 404 on DELETE missing resources
* Test for 404 when try to GET non existent resource
* Test for saved tags in posts
* Test for searching posts
* Add extra fixtures to support this
* Test for 404 on PUT/updating a non-existent resource
* Test GET /posts with GeoJSON and JSONP formats
* Test for PUT /posts with partial data.
* Test missing values in PUT /posts are ignored not removed
* Test GET /posts with limit/offset and orderby/order
* Test POST/PUT /posts with invalid relation IDs
* Test PUT /posts with invalid form id
* Test creating/updating groups and attributes with invalid form id
* Test creating/updating attributes with invalid groups
* Check for next/prev/curr properties on the /posts limit+offset test

General testing improvements:
* Ability to test failed requests (ie. 400/500/404)
* Add thePropertyContains() step, used to check for tags.
* Use base_url from Guzzle
* Add support for setting query strings in tests
* Improve error message for property equals
* Better handling of JSON errors in tests
* Add test step for JSONP
* Add test step for response does NOT have a property
* theTypeOfThePropertyIsNumeric() converted to theTypeOfThePropertyIs()
with ability to add further type support
* Fix thePropertyEquals() to handle numeric values
Make comparison less strict since value from behat is always a string
* Ability to check deeply nested values in json response ie. values.last_location

Extras
* Add option to configure proxy url for testing
* Add JSONP support
* Improve 'invalid json' error in Api controller to use json_last_error() and get more info