Remove warning about track_associations default
Failing to set PaperTrail.config.track_associations will no longer produce a warning. The default (false) will remain the same.
This commit is contained in:
parent
fd3f41584e
commit
f206882bfb
|
@ -18,18 +18,17 @@ module PaperTrail
|
|||
@serializer = PaperTrail::Serializers::YAML
|
||||
end
|
||||
|
||||
# Previously, we checked `PaperTrail::VersionAssociation.table_exists?`
|
||||
# As of PaperTrail 5, `track_associations?` 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
|
||||
#
|
||||
# In PT 4, 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?
|
||||
ActiveSupport::Deprecation.warn <<-EOS.strip_heredoc.gsub(/\s+/, " ")
|
||||
PaperTrail.config.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
|
||||
|
|
|
@ -16,16 +16,14 @@ module PaperTrail
|
|||
|
||||
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
|
||||
expect(config.track_associations?).to eq(false)
|
||||
end
|
||||
|
||||
after do
|
||||
PaperTrail.config.track_associations = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue