goncalossilva/rails3_acts_as_paranoid — pull request #51 by softcraft-development (2012-01-24 19:04:16+00:00)
Title: rails3_acts_as_paranoid regression tests, relations, and bug fixes.

Hello again. Sorry for the delay, but I've finally gotten a chance to catch up on my backlog of work.

I am working on a project to upgrade our app from Rails 2.3.10 to 3.1. As a part of that, we chose your gem to replace the old `acts_as_paranoid` gem. (And thank you very much for taking on that project BTW.)

During the upgrade, we noticed that some of our tests were breaking. We traced this to differences in the behaviour from `acts_as_paranoid` (which we had built tests around) to `rails3_acts_as_paranoid`. As you might expect, the differences were largely in edge cases, not implemented in your gem or covered by your test cases.

Since we had a lot of application functionality built around that behaviour, we decided to fork the gem and add in the functionality we needed. We built a set of tests (originally in the Rails 2/`acts_as_paranoid` version of our app) specifically designed to verify that behaviour, then added code into our own `rails3_acts_as_paranoid` for until they passed. (Those tests, when scrubbed of business context, became [more_paranoid_test.rb](https://github.com/softcraft-development/rails3_acts_as_paranoid/blob/8f4202625bda7d0ed63b0046344eb6ed82ce7d19/test/more_paranoid_test.rb).

I'll leave it up to you whether you pull these changes into your repository. The functionality we added isn't absolutely necessary, depending on the vision you have for the gem going forward. We just needed it to avoid breaking our app. However, we did add some nifty features, so it may be worthwhile to pull it into the main codebase.

Here's what we did:
* Updated the requirements to [Rails 3.1](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/d285a89155fcb5f2e3eb57f7359dc3f80923ee12).
** As I mentioned earlier, the underlying ActiveRecord code changed drastically between Rails 3.0 and 3.1.
** I haven't even begun to research whether we'll need another round of changes for Rails 3.2
* Added the ability to [find all deleted records through a Relation](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/744ebb61414284f816a05f53a18c7e2805773bf1) (association)
** In the original code, calling `with_deleted` dropped *all* scopes from the association, including the one that joined the two tables together.
* Fixed an issue that caused [violations of validate_uniquess_of](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/ca857ee2f9a519e3b00f10184fae136b5116f032) during paranoid deletions.
* Added the ability to [paranoid delete/destroy all records through a relation](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/f09e90e2a8599b71fc09d24373fd98591e254535).
* [Removed the deprecated aliasing of `primary_key_name'](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/819f99a6e6a904510eb132a40a61be1b076bc02f).
* [Fixed](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/5b57d70e0e9faae03fd8e0e2e3d5ef67fd2cf0de) [errors](https://github.com/softcraft-development/rails3_acts_as_paranoid/commit/040c0c8829b39387765af75352d276ae1c10dc61) in `uniqueness_without_deleted` relating to new Rails 3 code.
* Expanded the test coverage, particularly in cases of paranoid deleted associated records.

So far, it's been working really well for us. If you have any questions, just let me know.

Thanks,

Craig