diff --git a/CHANGELOG.md b/CHANGELOG.md index ce18b9c7d..5efb7da38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,21 @@ This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the recommendations of [keepachangelog.com](http://keepachangelog.com/). -## 6.0.0 (Unreleased) +## Unreleased + +### Breaking Changes + +- None + +### Added + +- None + +### Fixed + +- None + +## 6.0.0 (2016-12-03) Now with rails 5.1 support, and less model pollution! About 40 methods that were polluting your models' namespaces have been removed, reducing the chances of a diff --git a/README.md b/README.md index 60bea0086..df1e7c5fc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ has been destroyed. | Version | Documentation | | -------------- | ------------- | -| Unreleased | https://github.com/airblade/paper_trail/blob/master/README.md | +| 6.0.0 | https://github.com/airblade/paper_trail/blob/master/README.md | | 5.2.3 | https://github.com/airblade/paper_trail/blob/v5.2.3/README.md | | 4.2.0 | https://github.com/airblade/paper_trail/blob/v4.2.0/README.md | | 3.0.9 | https://github.com/airblade/paper_trail/blob/v3.0.9/README.md | @@ -62,7 +62,7 @@ has been destroyed. | paper_trail | branch | tags | ruby | activerecord | | -------------- | ---------- | ------ | -------- | ------------- | -| 6 (unreleased) | master | | >= 1.9.3 | >= 4.0, < 6 | +| 6 | master | v6.x | >= 1.9.3 | >= 4.0, < 6 | | 5 | 5-stable | v5.x | >= 1.9.3 | >= 3.0, < 5.1 | | 4 | 4-stable | v4.x | >= 1.8.7 | >= 3.0, < 5.1 | | 3 | 3.0-stable | v3.x | >= 1.8.7 | >= 3.0, < 5 | diff --git a/lib/paper_trail/record_trail.rb b/lib/paper_trail/record_trail.rb index aefb74910..05b66a2f7 100644 --- a/lib/paper_trail/record_trail.rb +++ b/lib/paper_trail/record_trail.rb @@ -456,6 +456,42 @@ def add_transaction_id_to(data) data[:transaction_id] = PaperTrail.transaction_id end + # @api private + def attribute_changed_in_latest_version?(attr_name) + if @in_after_callback && RAILS_GTE_5_1 + @record.saved_change_to_attribute?(attr_name.to_s) + else + @record.attribute_changed?(attr_name.to_s) + end + end + + # @api private + def attribute_in_previous_version(attr_name) + if @in_after_callback && RAILS_GTE_5_1 + @record.attribute_before_last_save(attr_name.to_s) + else + @record.attribute_was(attr_name.to_s) + end + end + + # @api private + def changed_in_latest_version + if @in_after_callback && RAILS_GTE_5_1 + @record.saved_changes.keys + else + @record.changed + end + end + + # @api private + def changes_in_latest_version + if @in_after_callback && RAILS_GTE_5_1 + @record.saved_changes + else + @record.changes + end + end + # Given a HABTM association, returns an array of ids. # @api private def habtm_assoc_ids(habtm_assoc) @@ -502,37 +538,5 @@ def version def versions @record.public_send(@record.class.versions_association_name) end - - def attribute_in_previous_version(attr_name) - if @in_after_callback && RAILS_GTE_5_1 - @record.attribute_before_last_save(attr_name.to_s) - else - @record.attribute_was(attr_name.to_s) - end - end - - def changed_in_latest_version - if @in_after_callback && RAILS_GTE_5_1 - @record.saved_changes.keys - else - @record.changed - end - end - - def changes_in_latest_version - if @in_after_callback && RAILS_GTE_5_1 - @record.saved_changes - else - @record.changes - end - end - - def attribute_changed_in_latest_version?(attr_name) - if @in_after_callback && RAILS_GTE_5_1 - @record.saved_change_to_attribute?(attr_name.to_s) - else - @record.attribute_changed?(attr_name.to_s) - end - end end end diff --git a/lib/paper_trail/version_number.rb b/lib/paper_trail/version_number.rb index b7497fbde..6ceb05849 100644 --- a/lib/paper_trail/version_number.rb +++ b/lib/paper_trail/version_number.rb @@ -4,7 +4,7 @@ module VERSION MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "pre".freeze + PRE = nil STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze diff --git a/paper_trail.gemspec b/paper_trail.gemspec index 8f94bb42e..ba583209b 100644 --- a/paper_trail.gemspec +++ b/paper_trail.gemspec @@ -20,11 +20,8 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.required_ruby_version = ">= 1.9.3" - # Rails 5.1 will deprecate the current behavior of AR::Dirty - # (https://github.com/rails/rails/pull/25337) which is pretty important - # to PT. I haven't found good instructions yet on how to upgrade, but - # Sean Griffin described it as easy, on his podcast (http://bikeshed.fm/87). - s.add_dependency "activerecord", [">= 4.0", "< 5.1"] + # Rails does not follow semver, makes breaking changes in minor versions. + s.add_dependency "activerecord", [">= 4.0", "< 5.2"] s.add_dependency "request_store", "~> 1.1" s.add_development_dependency "appraisal", "~> 2.1"