alphagov/whitehall — pull request #1006 by elliotcm (2013-11-05 11:32:05+00:00)
Title: Supporting pages become editions

https://www.pivotaltracker.com/story/show/57310924

This pull request includes the bulk of the work to make supporting pages editions with passing tests. We're aware the current tests aren't passing, but these are small regressions introduced by the merge. Please go ahead with a review.

The following tasks remain before this can be shipped:
- [ ] Add search indexing for supporting pages and ensure the front-end looks sensible
- [ ] Add cleanup migration for old `supporting_pages` table

The following tasks are part of the ticket but should not block deploy:
- Update change notes & alerts on related policies when publishing supporting pages

There's also a whole lot of tech debt which we're not going to tackle here:
- Edition mixins don't reliably include other mixins they depend on, e.g. `can_apply_to_local..` relies on `related_policies` but does not include it, and the attachable mixin relies on the alternative format provider.
- Some Edition mixins provide `#can_be_something?` methods whereas others check concrete descendants to provide a list of edition types. This should be one or the other or perhaps neither.
- Editions are used in places where documents would be more appropriate, including relationships between different documents. The word "document" is also used in many places when actually referring to editions, see https://github.com/alphagov/whitehall/blob/master/app/controllers/documents_controller.rb#L46-L52 which always returns an edition.
- `Edition::Organisations` is mixed into `Speech` and `WorldLocationNewsArticle` but is not used. This can now be extracted based on the work contained in this PR.
- The `AuthorityTestHelper` is shit. Let's remove it.
- Edition mixins should be unit tested independently with test-specific subclasses instead of relying on either generic editions or other unrelated concrete subtypes.
- Attachment behaviour should only be tested through the attachment controller tests, not the controller tests for the specific attachables, e.g. publication and consultations.