Skip to content

Commit

Permalink
close #438; PaperTrail::Model::ClassMethods#paper_trail_enabled_for_m…
Browse files Browse the repository at this point in the history
…odel? should return false if has_paper_trail isn't declared on the class in question
  • Loading branch information
batter committed Oct 31, 2014
1 parent 678b766 commit be5f192
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,8 @@
PaperTrail::Rails::Engine.eager_load!
```

- [#438](https://github.com/airblade/paper_trail/issues/438) - `Model.paper_trail_enabled_for_model?` should return `false` if
`has_paper_trail` has not been declared on the class.
- [#427](https://github.com/airblade/paper_trail/pull/427) - Fix `reify` method in context of model where a column has been removed.
- [#414](https://github.com/airblade/paper_trail/issues/414) - Fix functionality `ignore` argument to `has_paper_trail`
in `ActiveRecord` 4.
Expand Down
1 change: 1 addition & 0 deletions lib/paper_trail/has_paper_trail.rb
Expand Up @@ -101,6 +101,7 @@ def paper_trail_on
end

def paper_trail_enabled_for_model?
return false unless self.include?(PaperTrail::Model::InstanceMethods)
PaperTrail.enabled_for_model?(self)
end

Expand Down
19 changes: 19 additions & 0 deletions spec/models/fluxor_spec.rb
@@ -0,0 +1,19 @@
require 'rails_helper'

describe Fluxor, :type => :model do
describe '`be_versioned` matcher' do
it { is_expected.to_not be_versioned }
end

describe "Methods" do
describe "Class" do
subject { Fluxor }

describe "#paper_trail_enabled_for_model?" do
it { is_expected.to respond_to(:paper_trail_enabled_for_model?) }

it { expect(subject.paper_trail_enabled_for_model?).to be false }
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/gadget_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'

describe Gadget, :type => :model do
it { should be_versioned }
it { is_expected.to be_versioned }

let(:gadget) { Gadget.create!(:name => 'Wrench', :brand => 'Acme') }

Expand Down
8 changes: 7 additions & 1 deletion spec/models/widget_spec.rb
Expand Up @@ -2,7 +2,7 @@

describe Widget, :type => :model do
describe '`be_versioned` matcher' do
it { should be_versioned }
it { is_expected.to be_versioned }
end

let(:widget) { Widget.create! :name => 'Bob', :an_integer => 1 }
Expand Down Expand Up @@ -225,6 +225,12 @@
describe "Class" do
subject { Widget }

describe "#paper_trail_enabled_for_model?" do
it { is_expected.to respond_to(:paper_trail_enabled_for_model?) }

it { expect(subject.paper_trail_enabled_for_model?).to be true }
end

describe '#paper_trail_off!' do
it { is_expected.to respond_to(:paper_trail_off!) }

Expand Down
1 change: 0 additions & 1 deletion test/dummy/app/models/post.rb
@@ -1,4 +1,3 @@
class Post < ActiveRecord::Base
has_paper_trail :class_name => "PostVersion"

end

0 comments on commit be5f192

Please sign in to comment.