mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
parent
52881f2ece
commit
5bb0902816
7 changed files with 55 additions and 45 deletions
|
@ -117,6 +117,15 @@ Naming/PredicateName:
|
||||||
Naming/MethodParameterName:
|
Naming/MethodParameterName:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# This cop has low value to begin with. Also, secondarily, it does not allow
|
||||||
|
# reasonable names like `rails_lt_6_0`.
|
||||||
|
Naming/VariableNumber:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
# Good advice for rails applications, but not applicable to libraries like PT.
|
||||||
|
Rails/SkipsModelValidations:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
# This cop does not seem to work in rubocop-rspec 1.28.0
|
# This cop does not seem to work in rubocop-rspec 1.28.0
|
||||||
RSpec/DescribeClass:
|
RSpec/DescribeClass:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
|
@ -101,22 +101,6 @@ Rails/RedundantForeignKey:
|
||||||
- 'spec/dummy_app/app/models/family/family_line.rb'
|
- 'spec/dummy_app/app/models/family/family_line.rb'
|
||||||
- 'spec/dummy_app/app/models/person.rb'
|
- 'spec/dummy_app/app/models/person.rb'
|
||||||
|
|
||||||
# Offense count: 28
|
|
||||||
# Configuration parameters: ForbiddenMethods, AllowedMethods.
|
|
||||||
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
|
|
||||||
Rails/SkipsModelValidations:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/paper_trail/record_trail.rb'
|
|
||||||
- 'spec/models/gadget_spec.rb'
|
|
||||||
- 'spec/models/on/create_spec.rb'
|
|
||||||
- 'spec/models/on/empty_array_spec.rb'
|
|
||||||
- 'spec/models/on/touch_spec.rb'
|
|
||||||
- 'spec/models/on/update_spec.rb'
|
|
||||||
- 'spec/models/widget_spec.rb'
|
|
||||||
- 'spec/paper_trail/cleaner_spec.rb'
|
|
||||||
- 'spec/paper_trail/config_spec.rb'
|
|
||||||
- 'spec/paper_trail/model_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Rails/WhereNot:
|
Rails/WhereNot:
|
||||||
|
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -11,12 +11,18 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `where_attribute_changes` queries for versions where the object's attribute
|
- [#1292](https://github.com/paper-trail-gem/paper_trail/pull/1292) -
|
||||||
|
`where_attribute_changes` queries for versions where the object's attribute
|
||||||
changed to or from any values.
|
changed to or from any values.
|
||||||
|
- [#1291](https://github.com/paper-trail-gem/paper_trail/pull/1291) -
|
||||||
|
`where_object_changes_to` queries for versions where the object's attributes
|
||||||
|
changed to one set of known values from any other set of values.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- None
|
- [#1285](https://github.com/paper-trail-gem/paper_trail/pull/1285) -
|
||||||
|
For ActiveRecord >= 6.0, the `touch` callback will no longer create a new
|
||||||
|
`Version` for skipped or ignored attributes.
|
||||||
|
|
||||||
## 12.0.0 (2021-03-29)
|
## 12.0.0 (2021-03-29)
|
||||||
|
|
||||||
|
@ -31,8 +37,6 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `where_object_changes_to` queries for versions where the object's attributes
|
|
||||||
changed to one set of known values from any other set of values.
|
|
||||||
- `where_object_changes_from` queries for versions where the object's attributes
|
- `where_object_changes_from` queries for versions where the object's attributes
|
||||||
changed from one set of known values to any other set of values.
|
changed from one set of known values to any other set of values.
|
||||||
|
|
||||||
|
@ -43,10 +47,6 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
||||||
- Expand kwargs passed to `save_with_version` using double splat operator - Rails 6.1 compatibility
|
- Expand kwargs passed to `save_with_version` using double splat operator - Rails 6.1 compatibility
|
||||||
- [#1287](https://github.com/paper-trail-gem/paper_trail/issues/1287) - Fix 'rails db:migrate' error when run against an app with mysql2 adapter
|
- [#1287](https://github.com/paper-trail-gem/paper_trail/issues/1287) - Fix 'rails db:migrate' error when run against an app with mysql2 adapter
|
||||||
|
|
||||||
- [#1285](https://github.com/paper-trail-gem/paper_trail/pull/1285) -
|
|
||||||
Touch callback does not create a new version for skipped or ignored attributes
|
|
||||||
for ActiveRecord 6.0 and higher
|
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
- Drop support for ruby 2.4 (reached EoL on 2020-03-31)
|
- Drop support for ruby 2.4 (reached EoL on 2020-03-31)
|
||||||
|
|
48
README.md
48
README.md
|
@ -10,21 +10,23 @@ has been destroyed.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
| Version | Documentation |
|
This is the _user guide_. See also, the
|
||||||
| -------------- | ------------- |
|
[API reference](https://www.rubydoc.info/gems/paper_trail).
|
||||||
| Unreleased | https://github.com/paper-trail-gem/paper_trail/blob/master/README.md |
|
|
||||||
| 12.0.0 | https://github.com/paper-trail-gem/paper_trail/blob/v12.0.0/README.md |
|
Choose version:
|
||||||
| 11.1.0 | https://github.com/paper-trail-gem/paper_trail/blob/v11.1.0/README.md |
|
[Unreleased](https://github.com/paper-trail-gem/paper_trail/blob/master/README.md),
|
||||||
| 10.3.1 | https://github.com/paper-trail-gem/paper_trail/blob/v10.3.1/README.md |
|
[12.0](https://github.com/paper-trail-gem/paper_trail/blob/v12.0.0/README.md),
|
||||||
| 9.2.0 | https://github.com/paper-trail-gem/paper_trail/blob/v9.2.0/README.md |
|
[11.1](https://github.com/paper-trail-gem/paper_trail/blob/v11.1.0/README.md),
|
||||||
| 8.1.2 | https://github.com/paper-trail-gem/paper_trail/blob/v8.1.2/README.md |
|
[10.3](https://github.com/paper-trail-gem/paper_trail/blob/v10.3.1/README.md),
|
||||||
| 7.1.3 | https://github.com/paper-trail-gem/paper_trail/blob/v7.1.3/README.md |
|
[9.2](https://github.com/paper-trail-gem/paper_trail/blob/v9.2.0/README.md),
|
||||||
| 6.0.2 | https://github.com/paper-trail-gem/paper_trail/blob/v6.0.2/README.md |
|
[8.1](https://github.com/paper-trail-gem/paper_trail/blob/v8.1.2/README.md),
|
||||||
| 5.2.3 | https://github.com/paper-trail-gem/paper_trail/blob/v5.2.3/README.md |
|
[7.1](https://github.com/paper-trail-gem/paper_trail/blob/v7.1.3/README.md),
|
||||||
| 4.2.0 | https://github.com/paper-trail-gem/paper_trail/blob/v4.2.0/README.md |
|
[6.0](https://github.com/paper-trail-gem/paper_trail/blob/v6.0.2/README.md),
|
||||||
| 3.0.9 | https://github.com/paper-trail-gem/paper_trail/blob/v3.0.9/README.md |
|
[5.2](https://github.com/paper-trail-gem/paper_trail/blob/v5.2.3/README.md),
|
||||||
| 2.7.2 | https://github.com/paper-trail-gem/paper_trail/blob/v2.7.2/README.md |
|
[4.2](https://github.com/paper-trail-gem/paper_trail/blob/v4.2.0/README.md),
|
||||||
| 1.6.5 | https://github.com/paper-trail-gem/paper_trail/blob/v1.6.5/README.md |
|
[3.0](https://github.com/paper-trail-gem/paper_trail/blob/v3.0.9/README.md),
|
||||||
|
[2.7](https://github.com/paper-trail-gem/paper_trail/blob/v2.7.2/README.md),
|
||||||
|
[1.6](https://github.com/paper-trail-gem/paper_trail/blob/v1.6.5/README.md)
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
|
@ -85,8 +87,8 @@ has been destroyed.
|
||||||
| paper_trail | branch | ruby | activerecord |
|
| paper_trail | branch | ruby | activerecord |
|
||||||
| -------------- | ---------- | -------- | ------------- |
|
| -------------- | ---------- | -------- | ------------- |
|
||||||
| unreleased | master | >= 2.5.0 | >= 5.2, < 6.2 |
|
| unreleased | master | >= 2.5.0 | >= 5.2, < 6.2 |
|
||||||
| 12 | master | >= 2.5.0 | >= 5.2, < 6.2 |
|
| 12 | 12-stable | >= 2.5.0 | >= 5.2, < 6.2 |
|
||||||
| 11 | master | >= 2.4.0 | >= 5.2, < 6.1 |
|
| 11 | 11-stable | >= 2.4.0 | >= 5.2, < 6.1 |
|
||||||
| 10 | 10-stable | >= 2.3.0 | >= 4.2, < 6.1 |
|
| 10 | 10-stable | >= 2.3.0 | >= 4.2, < 6.1 |
|
||||||
| 9 | 9-stable | >= 2.3.0 | >= 4.2, < 5.3 |
|
| 9 | 9-stable | >= 2.3.0 | >= 4.2, < 5.3 |
|
||||||
| 8 | 8-stable | >= 2.2.0 | >= 4.2, < 5.2 |
|
| 8 | 8-stable | >= 2.2.0 | >= 4.2, < 5.2 |
|
||||||
|
@ -720,8 +722,16 @@ PaperTrail::Version.where_object(content: 'Hello', title: 'Article')
|
||||||
PaperTrail::Version.where_object_changes(atr: 'v')
|
PaperTrail::Version.where_object_changes(atr: 'v')
|
||||||
```
|
```
|
||||||
|
|
||||||
Using `where_object_changes` to read YAML from a text column was deprecated in
|
See also:
|
||||||
8.1.0, and will now raise an error.
|
|
||||||
|
- `where_object_changes_from`
|
||||||
|
- `where_object_changes_to`
|
||||||
|
- `where_attribute_changes`
|
||||||
|
|
||||||
|
Using `where_object_changes*` or `where_attribute_changes` to read YAML or JSON
|
||||||
|
from a text column was deprecated in 8.1.0, and will now raise an error. Use a
|
||||||
|
`json` or `jsonb` column if possible. If you must use a `text` column, you'll
|
||||||
|
have to write a custom `object_changes_adapter`.
|
||||||
|
|
||||||
### 3.c. Diffing Versions
|
### 3.c. Diffing Versions
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,13 @@ module PaperTrail
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a callback that records a version after a "touch" event.
|
# Adds a callback that records a version after a "touch" event.
|
||||||
|
#
|
||||||
|
# Rails < 6.0 has a bug where dirty-tracking does not occur during
|
||||||
|
# a `touch`. (https://github.com/rails/rails/issues/33429) See also:
|
||||||
|
# https://github.com/paper-trail-gem/paper_trail/issues/1121
|
||||||
|
# https://github.com/paper-trail-gem/paper_trail/issues/1161
|
||||||
|
# https://github.com/paper-trail-gem/paper_trail/pull/1285
|
||||||
|
#
|
||||||
# @api public
|
# @api public
|
||||||
def on_touch
|
def on_touch
|
||||||
@model_class.after_touch { |r|
|
@model_class.after_touch { |r|
|
||||||
|
|
|
@ -18,7 +18,7 @@ module PaperTrail
|
||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
def execute
|
def execute
|
||||||
if PaperTrail.config.object_changes_adapter&.respond_to?(:where_attribute_changes)
|
if PaperTrail.config.object_changes_adapter.respond_to?(:where_attribute_changes)
|
||||||
return PaperTrail.config.object_changes_adapter.where_attribute_changes(
|
return PaperTrail.config.object_changes_adapter.where_attribute_changes(
|
||||||
@version_model_class, @attribute
|
@version_model_class, @attribute
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ module PaperTrail
|
||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
def execute
|
def execute
|
||||||
if PaperTrail.config.object_changes_adapter&.respond_to?(:where_object_changes_to)
|
if PaperTrail.config.object_changes_adapter.respond_to?(:where_object_changes_to)
|
||||||
return PaperTrail.config.object_changes_adapter.where_object_changes_to(
|
return PaperTrail.config.object_changes_adapter.where_object_changes_to(
|
||||||
@version_model_class, @attributes
|
@version_model_class, @attributes
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue