Rename DocumentIdentity to DocIdentity.

- This is a first step towards renaming Document to Edition.
- It should just be a simple rename. Thankfully no routes are affected.
- All the tests are passing.
- By changing the name of DocumentIdentity to something not including
  the word Document it will be easier to discriminate between
  DocumentIdentity and Document when using search and replace tools.
Rename "documents" table to "editions".

- The Document class now uses "editions" table, but is otherwise left
  unchanged.
- It would be nice to rename Document to Edition, but this would have
  been a huge change in one commit and this way we can still make a
  useful incremental change while keeping the tests passing. It does mean
  the temporary addition of some complexity, but this will go away once we
  rename the class in a later commit.
- Foreign keys referring to "document_id" are changed to "edition_id"
  (although those referring to subclasses of Document e.g. "policy_id"
  are left unchanged).
- A number of migrations had to be updated, because they assumed the
  Document class uses the "documents" table.
- This means that all "has_many" definitions on Document and
  "belongs_to" definitions referring to Document, now have to explicitly
  declare the "edition_id" foreign key.
- It was necessary to disable the "auto_scopes" option on the
  Transitions state machine - unfortunately these use the default model
  table name and ignore the actual table name.
- It's interesting to note that although you'd hope this change was
  limited to only the model layer, it leaks out into a few controllers.
- It's more pleasing to note that only one test needed any change in
  this commit, so it's almost a pure refactoring.
- Indexes were removed and added in the new migration in order that the
  indexes continue to have a sensible name i.e. referring to their
  "parent" table.
Avoid directly instantiating models in tests.

Using FactoryGirl consistently makes the tests independent of changes to
validation and makes the tests more realistic, because the model
instances should be valid by definition.
Avoid directly instantiating models in tests.

Using FactoryGirl consistently makes the tests independent of
changes to validation and makes the tests more realistic, because
the model instances should be valid by definition.
Rename Document to Edition.

- The business talk about a document and its editions; whereas we are
  modelling them as a document identity and its documents. To avoid
  confusion it is important that the nomenclatures are more aligned.
  This is one of a series of commits which aims to make this happen.
- The Document class is renamed to Edition. All document-related
  associations are renamed to match the new class name. Model code which
  uses these associations is updated accordingly. The document factory
  was renamed to be the edition factory.
- The scope of this commit was significantly reduced by using the
  following tricks :-

    * Adding aliases to the edition factories so that tests
      instantiating a document actually get an instance of an edition.
    * Adding a dummy Document class which passes all singleton method
      invocations on to the Edition class.
    * Adding FactoryGirlInterceptor to adapt the attributes passed from
      tests to the relevant factories. e.g. the `document_country`
      factory will now be expecting an `edition` attribute and not a
      `document` attribute. However many tests will be passing in a
      `document` attribute. The interceptor converts the `document`
      attribute into an `edition` attribute and obviates the need to
      modify the tests.
    * Aliasing old document-based methods on models to the new
      edition-based methods means we can insulate controllers and tests
      from the change to the models.
- As well as reducing the size of this commit, the above tricks mean
  that we will be able to make the remaining changes in a more
  incremental fashion.
- It's important to note that although all the tests are passing, the
  app probably isn't actually deployable at this point, because a number
  of the "tricks" are only applied in the `test_helper`.