18F/foia-hub — pull request #197 by konklone (2014-11-08 23:01:22+00:00)
Title: Adds office_slug field to Office model

This adds an `office_slug` field to the Office model. Previously:

* an Agency had a `slug`, e.g. `department-of-defense`
* an Office had a `slug` that was the **combined** slug of the agency and office, e.g. `department-of-defense--department-of-the-air-force-headquartersicio-foia`

This gives an Office an `office_slug` field, e.g. `department-of-the-air-force-headquartersicio-foia`

This normalizes the data in a way I think is healthier and doesn't make the code split on `--` on demand. In fact, splitting on `--` isn't a perfect reversal of joining on `--`, because `--` could appear in either side of the slug being combined.

I added a migration that: adds the field, temporarily allowing NULL values, then generates values from the existing Office `name` field, then adds the non-NULL constraint. It does not add a uniqueness constraint (office slugs are not expected to be unique on their own).

This adds a test for office slugification, and fixes an existing one for agency slugification (it was checking the original object and not the `retrieved` copy it had fetched, which was not as thorough a test).