radar/paranoia — pull request #192 by sergey-alekseev (2014-12-14 09:46:32+00:00)
Title: Switch to rails 4 2

# Gist
The introduced test `test_counter_cache_column_update_on_destroy` with counter cache update on `#destroy` would break with Rails 4.2. The reason is Rails 4.2 changes introduced in this commit [Make counter cache decrementation on destroy idempotent](https://github.com/rails/rails/commit/655a3667aa99ae3f7e68024b3971b5783d6396bf). Try and compare:
```ruby
# On the commit 'Make counter cache decrementation on destroy idempotent'
# test_counter_cache_column_update_on_destroy fails
gem 'rails', github: 'rails', ref: '655a3667aa99ae3f7e68024b3971b5783d6396bf'
```

Another introduced test `test_counter_cache_column_update_on_really_destroy` with counter cache update on `#really_destroy!` would break with Rails < 4.2. It starts to succeed with the commit mentioned above. Try and compare with [the commit](https://github.com/rails/rails/commit/dd063f6ef436b5e6a594e70eeb50532a09ef7a57) done right before the [Make counter cache decrementation on destroy idempotent](https://github.com/rails/rails/commit/655a3667aa99ae3f7e68024b3971b5783d6396bf):
```ruby
# Right before the commit 'Make counter cache decrementation on destroy idempotent'
# test_counter_cache_column_update_on_really_destroy fails
gem 'rails', github: 'rails', ref: 'dd063f6ef436b5e6a594e70eeb50532a09ef7a57'
```

## Notes
Apart of the fix I felt free to refactor the code a bit, remove 3 annoying deprecation warnings and add 1 deprecation warning (helpful for future compatibility).

Not sure whether `#restore` should increment counter cache back. In my current application I need it to be the same behaviour as it's now – don't increment counter cache after restore. So I leave it as is. Let me know if you need this behaviour, I'd include the commit to this or separate PR. The test for `#restore` is simple:
```ruby
assert_equal 0, parent_model_with_counter_cache_column.reload.related_models_count
related_model.restore
assert_equal 1, parent_model_with_counter_cache_column.reload.related_models_count
```

Another proposal: probably it would be good to bump a minor version with Rails 4.2 support. I've noticed you didn't bumb it for Rails 4.1.

BTW love the gem! :heart: It does a good job.

## TODO (for myself)
fix the bug with counter cache and destroy