Permalink
Browse files

close #307, close #326, close #328; Make Model.paper_trail_enabled_fo…

…r_model? thread-safe
  • Loading branch information...
1 parent 95a50ae commit 035970475163c4ca60961e8b306e396afc94e456 @batter batter committed Feb 20, 2014
Showing with 18 additions and 11 deletions.
  1. +6 −3 CHANGELOG.md
  2. +6 −2 lib/paper_trail/has_paper_trail.rb
  3. +6 −6 spec/models/widget_spec.rb
View
@@ -1,5 +1,8 @@
## 3.0.1 (Unreleased)
+ - [#328](https://github.com/airblade/paper_trail/pull/328) / [#326](https://github.com/airblade/paper_trail/issues/326)/
+ [#307](https://github.com/airblade/paper_trail/issues/307) - `Model.paper_trail_enabled_for_model?` and
+ `model_instance.without_versioning` is now thread-safe.
- [#316](https://github.com/airblade/paper_trail/issues/316) - `user_for_paper_trail` should default to `current_user.try(:id)`
instead of `current_user` (if `current_user` is defined).
- [#313](https://github.com/airblade/paper_trail/pull/313) - Make the `Rails::Controller` helper compatible with
@@ -44,11 +47,11 @@
## 2.7.2
- [#228](https://github.com/airblade/paper_trail/issues/228) - Refactored default `user_for_paper_trail` method implementation
- so that `current_user` only gets invoked if it is defined.
+ so that `current_user` only gets invoked if it is defined.
- [#219](https://github.com/airblade/paper_trail/pull/219) - Fixed issue where attributes stored with `nil` value might not get
- reified properly depending on the way the serializer worked.
+ reified properly depending on the way the serializer worked.
- [#213](https://github.com/airblade/paper_trail/issues/213) - Added a `version_limit` option to the `PaperTrail::Config` options
- that can be used to restrict the number of versions PaperTrail will store per object instance.
+ that can be used to restrict the number of versions PaperTrail will store per object instance.
- [#187](https://github.com/airblade/paper_trail/pull/187) - Confirmed JRuby support.
- [#174](https://github.com/airblade/paper_trail/pull/174) - The `event` field on the versions table can now be customized.
@@ -203,9 +203,13 @@ def next_version
nil
end
+ def paper_trail_enabled_for_model?
+ self.class.paper_trail_enabled_for_model?
+ end
+
# Executes the given method or block without creating a new version.
def without_versioning(method = nil)
- paper_trail_was_enabled = self.class.paper_trail_enabled_for_model?
+ paper_trail_was_enabled = self.paper_trail_enabled_for_model?
self.class.paper_trail_off!
method ? method.to_proc.call(self) : yield
ensure
@@ -334,7 +338,7 @@ def changed_and_not_ignored
end
def paper_trail_switched_on?
- PaperTrail.enabled? && PaperTrail.enabled_for_controller? && self.class.paper_trail_enabled_for_model?
+ PaperTrail.enabled? && PaperTrail.enabled_for_controller? && self.paper_trail_enabled_for_model?
end
def save_version?
View
@@ -27,10 +27,10 @@
describe :paper_trail_off! do
it { should respond_to(:paper_trail_off!) }
- it 'should set the `paper_trail_enabled_for_model` to `false`' do
- subject.paper_trail_enabled_for_model.should be_true
+ it 'should set the `paper_trail_enabled_for_model?` to `false`' do
+ subject.paper_trail_enabled_for_model?.should be_true
subject.paper_trail_off!
- subject.paper_trail_enabled_for_model.should be_false
+ subject.paper_trail_enabled_for_model?.should be_false
end
end
@@ -54,10 +54,10 @@
it { should respond_to(:paper_trail_on!) }
- it 'should set the `paper_trail_enabled_for_model` to `true`' do
- subject.paper_trail_enabled_for_model.should be_false
+ it 'should set the `paper_trail_enabled_for_model?` to `true`' do
+ subject.paper_trail_enabled_for_model?.should be_false
subject.paper_trail_on!
- subject.paper_trail_enabled_for_model.should be_true
+ subject.paper_trail_enabled_for_model?.should be_true
end
end

0 comments on commit 0359704

Please sign in to comment.