leapcode/leap_web — pull request #73 by azul (2013-08-30 09:26:21+00:00)
Title: Bugfix/3623 teardown test data properly

Billing tests are currently failing because of
```
CouchRest::Model::Errors::Validations: Validation Failed: Login has already been taken
```

This is because another test left behind some user or identity records. We need to make sure we clean up all data we create at the end of a test.

This pull request also includes the combination of the account_settings and the signup_service into an Account Model. It's a composition to handle User and its identities

We have a lot of things that act upon a user record and one or more of it's ide
* Sing up: Create a user and it's initial identity
* Rename: Change the username and create a new identity, turn old into an alia
* Cancel Account: Remove user and all their identities.

In order to keep the User and Identity behaviour isolated but still have a this logic represented in a sinle place the Account model deals with all these things.

We could have overwritten the User#create, User#update and User#destroy methods instead. But then we would always create identities, even if we only need a user (for example in tests).

It's related to this pull request because in some Functional tests we were mocking the User.create call. But not the Identity.create call. So the Identity would be left behind. Now we mock Account.create which would take care of creating them both.