parent
a55eb9b7a8
commit
e36ba138a3
|
@ -5,6 +5,8 @@
|
|||
- [#758](https://github.com/airblade/paper_trail/pull/758) -
|
||||
`PaperTrail.config.track_associations` getter method removed,
|
||||
use `track_associations?` instead.
|
||||
- [#740](https://github.com/airblade/paper_trail/issues/740) -
|
||||
`PaperTrail.config.track_associations?` now defaults to false
|
||||
- [#723](https://github.com/airblade/paper_trail/pull/723) -
|
||||
`PaperTrail.enabled=` now affects all threads
|
||||
- [#556](https://github.com/airblade/paper_trail/pull/556) /
|
||||
|
|
|
@ -34,9 +34,19 @@ module PaperTrail
|
|||
)
|
||||
end
|
||||
|
||||
# Previously, we checked `PaperTrail::VersionAssociation.table_exists?`
|
||||
# here, but that proved to be problematic in situations when the database
|
||||
# connection had not been established, or when the database does not exist
|
||||
# yet (as with `rake db:create`).
|
||||
def track_associations?
|
||||
if @track_associations.nil?
|
||||
PaperTrail::VersionAssociation.table_exists?
|
||||
ActiveSupport::Deprecation.warn <<-EOS.strip_heredoc.gsub(/\s+/, " ")
|
||||
PaperTrail.track_associations has not been set. As of PaperTrail 5, it
|
||||
defaults to false. Tracking associations is an experimental feature so
|
||||
we recommend setting PaperTrail.config.track_associations = false in
|
||||
your config/initializers/paper_trail.rb
|
||||
EOS
|
||||
false
|
||||
else
|
||||
@track_associations
|
||||
end
|
||||
|
|
|
@ -13,5 +13,21 @@ module PaperTrail
|
|||
expect { described_class.new }.to raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "track_associations?" do
|
||||
context "@track_associations is nil" do
|
||||
after do
|
||||
PaperTrail.config.track_associations = true
|
||||
end
|
||||
|
||||
it "returns false and prints a deprecation warning" do
|
||||
config = described_class.instance
|
||||
config.track_associations = nil
|
||||
expect {
|
||||
expect(config.track_associations?).to eq(false)
|
||||
}.to output(/DEPRECATION WARNING/).to_stderr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Turn on associations tracking when the test suite is run on Travis CI
|
||||
PaperTrail.config.track_associations = true if ENV["TRAVIS"]
|
||||
PaperTrail.config.track_associations = true
|
||||
|
||||
module PaperTrail
|
||||
class Version < ActiveRecord::Base
|
||||
|
|
Loading…
Reference in New Issue