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:
Jared Beck 2017-12-10 21:49:19 -05:00
parent fd3f41584e
commit f206882bfb
2 changed files with 11 additions and 14 deletions

View File

@ -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

View File

@ -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