paper_trail 9.0.1 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/paper_trail/install_generator.rb +1 -1
- data/lib/paper_trail.rb +3 -0
- data/lib/paper_trail/config.rb +2 -2
- data/lib/paper_trail/model_config.rb +10 -2
- data/lib/paper_trail/record_trail.rb +28 -25
- data/lib/paper_trail/reifiers/has_one.rb +1 -1
- data/lib/paper_trail/serializers/json.rb +1 -1
- data/lib/paper_trail/serializers/yaml.rb +1 -1
- data/lib/paper_trail/version_number.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72cf4448b84e8e0f78e7be203e482f5c00b66801faa4a7ca518eb5e9676d97a7
|
4
|
+
data.tar.gz: e884a18e85ac0ff2acc31f1a568c4c9b9356b0ae48c7d9eee138ff98ae02a25d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab08ca6b72ae854eaf85e901f3c2ca090d70e04f32e65eb6f41fc6ee7699414ee5d7c889332b7d37f6a8f1ca82fa90394bee51f5d6ad7e25e9c7a440f5f3f00
|
7
|
+
data.tar.gz: cda3a9f844b20d635f0bb1317a528301ed754f2ae8d45bcc4f8461d2abb8eda5b4e87b6298a0bfb873407195c9d427959267a161a5d0cd0ddf396270973f5d30
|
@@ -73,7 +73,7 @@ module PaperTrail
|
|
73
73
|
private
|
74
74
|
|
75
75
|
# MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.
|
76
|
-
# See https://github.com/
|
76
|
+
# See https://github.com/paper-trail-gem/paper_trail/issues/651
|
77
77
|
def item_type_options
|
78
78
|
opt = { null: false }
|
79
79
|
opt[:limit] = 191 if mysql?
|
data/lib/paper_trail.rb
CHANGED
@@ -110,6 +110,9 @@ module PaperTrail
|
|
110
110
|
|
111
111
|
# Returns PaperTrail's `::Gem::Version`, convenient for comparisons. This is
|
112
112
|
# recommended over `::PaperTrail::VERSION::STRING`.
|
113
|
+
#
|
114
|
+
# Added in 7.0.0
|
115
|
+
#
|
113
116
|
# @api public
|
114
117
|
def gem_version
|
115
118
|
::Gem::Version.new(VERSION::STRING)
|
data/lib/paper_trail/config.rb
CHANGED
@@ -11,13 +11,13 @@ module PaperTrail
|
|
11
11
|
Association tracking is an endangered feature. For the past three or four
|
12
12
|
years it has been an experimental feature, not recommended for production.
|
13
13
|
It has a long list of known issues
|
14
|
-
(https://github.com/
|
14
|
+
(https://github.com/paper-trail-gem/paper_trail#4b1-known-issues) and has no
|
15
15
|
regular volunteers caring for it.
|
16
16
|
|
17
17
|
If you don't use this feature, I strongly recommend disabling it.
|
18
18
|
|
19
19
|
If you do use this feature, please head over to
|
20
|
-
https://github.com/
|
20
|
+
https://github.com/paper-trail-gem/paper_trail/issues/1070 and volunteer to work
|
21
21
|
on the known issues.
|
22
22
|
|
23
23
|
If we can't make a serious dent in the list of known issues over the next
|
@@ -106,7 +106,11 @@ module PaperTrail
|
|
106
106
|
}
|
107
107
|
@model_class.after_update { |r|
|
108
108
|
if r.paper_trail.save_version?
|
109
|
-
r.paper_trail.record_update(
|
109
|
+
r.paper_trail.record_update(
|
110
|
+
force: false,
|
111
|
+
in_after_callback: true,
|
112
|
+
is_touch: false
|
113
|
+
)
|
110
114
|
end
|
111
115
|
}
|
112
116
|
@model_class.after_update { |r|
|
@@ -120,7 +124,11 @@ module PaperTrail
|
|
120
124
|
# @api public
|
121
125
|
def on_touch
|
122
126
|
@model_class.after_touch { |r|
|
123
|
-
r.paper_trail.record_update(
|
127
|
+
r.paper_trail.record_update(
|
128
|
+
force: true,
|
129
|
+
in_after_callback: true,
|
130
|
+
is_touch: true
|
131
|
+
)
|
124
132
|
}
|
125
133
|
end
|
126
134
|
|
@@ -56,7 +56,7 @@ module PaperTrail
|
|
56
56
|
# > something) from running. By also stubbing out persisted? we can
|
57
57
|
# > actually prevent those. A more stable option might be to use suppress
|
58
58
|
# > instead, similar to the other branch in reify_has_one.
|
59
|
-
# > -Sean Griffin (https://github.com/
|
59
|
+
# > -Sean Griffin (https://github.com/paper-trail-gem/paper_trail/pull/899)
|
60
60
|
#
|
61
61
|
# @api private
|
62
62
|
def appear_as_new_record
|
@@ -73,10 +73,10 @@ module PaperTrail
|
|
73
73
|
}
|
74
74
|
end
|
75
75
|
|
76
|
-
def attributes_before_change
|
76
|
+
def attributes_before_change(is_touch)
|
77
77
|
Hash[@record.attributes.map do |k, v|
|
78
78
|
if @record.class.column_names.include?(k)
|
79
|
-
[k, attribute_in_previous_version(k)]
|
79
|
+
[k, attribute_in_previous_version(k, is_touch)]
|
80
80
|
else
|
81
81
|
[k, v]
|
82
82
|
end
|
@@ -204,7 +204,7 @@ module PaperTrail
|
|
204
204
|
if event != "create" &&
|
205
205
|
@record.has_attribute?(value) &&
|
206
206
|
attribute_changed_in_latest_version?(value)
|
207
|
-
attribute_in_previous_version(value)
|
207
|
+
attribute_in_previous_version(value, false)
|
208
208
|
else
|
209
209
|
@record.send(value)
|
210
210
|
end
|
@@ -240,8 +240,9 @@ module PaperTrail
|
|
240
240
|
# omitting attributes to be skipped.
|
241
241
|
#
|
242
242
|
# @api private
|
243
|
-
def object_attrs_for_paper_trail
|
244
|
-
attrs = attributes_before_change
|
243
|
+
def object_attrs_for_paper_trail(is_touch)
|
244
|
+
attrs = attributes_before_change(is_touch).
|
245
|
+
except(*@record.paper_trail_options[:skip])
|
245
246
|
AttributeSerializers::ObjectAttribute.new(@record.class).serialize(attrs)
|
246
247
|
attrs
|
247
248
|
end
|
@@ -315,7 +316,7 @@ module PaperTrail
|
|
315
316
|
item_id: @record.id,
|
316
317
|
item_type: @record.class.base_class.name,
|
317
318
|
event: @record.paper_trail_event || "destroy",
|
318
|
-
object: recordable_object,
|
319
|
+
object: recordable_object(false),
|
319
320
|
whodunnit: PaperTrail.request.whodunnit
|
320
321
|
}
|
321
322
|
add_transaction_id_to(data)
|
@@ -330,11 +331,11 @@ module PaperTrail
|
|
330
331
|
@record.class.paper_trail.version_class.column_names.include?("object_changes")
|
331
332
|
end
|
332
333
|
|
333
|
-
def record_update(force:, in_after_callback:)
|
334
|
+
def record_update(force:, in_after_callback:, is_touch:)
|
334
335
|
@in_after_callback = in_after_callback
|
335
336
|
if enabled? && (force || changed_notably?)
|
336
337
|
versions_assoc = @record.send(@record.class.versions_association_name)
|
337
|
-
version = versions_assoc.create(data_for_update)
|
338
|
+
version = versions_assoc.create(data_for_update(is_touch))
|
338
339
|
if version.errors.any?
|
339
340
|
log_version_errors(version, :update)
|
340
341
|
else
|
@@ -350,10 +351,10 @@ module PaperTrail
|
|
350
351
|
# `create`. That is, all the attributes of the nascent `Version` record.
|
351
352
|
#
|
352
353
|
# @api private
|
353
|
-
def data_for_update
|
354
|
+
def data_for_update(is_touch)
|
354
355
|
data = {
|
355
356
|
event: @record.paper_trail_event || "update",
|
356
|
-
object: recordable_object,
|
357
|
+
object: recordable_object(is_touch),
|
357
358
|
whodunnit: PaperTrail.request.whodunnit
|
358
359
|
}
|
359
360
|
if @record.respond_to?(:updated_at)
|
@@ -384,7 +385,7 @@ module PaperTrail
|
|
384
385
|
def data_for_update_columns(changes)
|
385
386
|
data = {
|
386
387
|
event: @record.paper_trail_event || "update",
|
387
|
-
object: recordable_object,
|
388
|
+
object: recordable_object(false),
|
388
389
|
whodunnit: PaperTrail.request.whodunnit
|
389
390
|
}
|
390
391
|
if record_object_changes?
|
@@ -401,11 +402,11 @@ module PaperTrail
|
|
401
402
|
# `PaperTrail.serializer`.
|
402
403
|
#
|
403
404
|
# @api private
|
404
|
-
def recordable_object
|
405
|
+
def recordable_object(is_touch)
|
405
406
|
if @record.class.paper_trail.version_class.object_col_is_json?
|
406
|
-
object_attrs_for_paper_trail
|
407
|
+
object_attrs_for_paper_trail(is_touch)
|
407
408
|
else
|
408
|
-
PaperTrail.serializer.dump(object_attrs_for_paper_trail)
|
409
|
+
PaperTrail.serializer.dump(object_attrs_for_paper_trail(is_touch))
|
409
410
|
end
|
410
411
|
end
|
411
412
|
|
@@ -507,7 +508,7 @@ module PaperTrail
|
|
507
508
|
::PaperTrail.request(enabled: false) do
|
508
509
|
@record.save!(validate: false)
|
509
510
|
end
|
510
|
-
record_update(force: true, in_after_callback: false)
|
511
|
+
record_update(force: true, in_after_callback: false, is_touch: false)
|
511
512
|
end
|
512
513
|
|
513
514
|
# Save, and create a version record regardless of options such as `:on`,
|
@@ -527,7 +528,7 @@ module PaperTrail
|
|
527
528
|
::PaperTrail.request(enabled: false) do
|
528
529
|
@record.save(*args)
|
529
530
|
end
|
530
|
-
record_update(force: true, in_after_callback: false)
|
531
|
+
record_update(force: true, in_after_callback: false, is_touch: false)
|
531
532
|
end
|
532
533
|
|
533
534
|
# Like the `update_column` method from `ActiveRecord::Persistence`, but also
|
@@ -603,7 +604,7 @@ module PaperTrail
|
|
603
604
|
end
|
604
605
|
|
605
606
|
# Rails 5.1 changed the API of `ActiveRecord::Dirty`. See
|
606
|
-
# https://github.com/
|
607
|
+
# https://github.com/paper-trail-gem/paper_trail/pull/899
|
607
608
|
#
|
608
609
|
# @api private
|
609
610
|
def attribute_changed_in_latest_version?(attr_name)
|
@@ -615,18 +616,20 @@ module PaperTrail
|
|
615
616
|
end
|
616
617
|
|
617
618
|
# Rails 5.1 changed the API of `ActiveRecord::Dirty`. See
|
618
|
-
# https://github.com/
|
619
|
+
# https://github.com/paper-trail-gem/paper_trail/pull/899
|
619
620
|
#
|
620
621
|
# Event can be any of the three (create, update, destroy).
|
621
622
|
#
|
622
623
|
# @api private
|
623
|
-
def attribute_in_previous_version(attr_name)
|
624
|
+
def attribute_in_previous_version(attr_name, is_touch)
|
624
625
|
if RAILS_GTE_5_1
|
625
|
-
if @in_after_callback
|
626
|
+
if @in_after_callback && !is_touch
|
627
|
+
# For most events, we want the original value of the attribute, before
|
628
|
+
# the last save.
|
626
629
|
@record.attribute_before_last_save(attr_name.to_s)
|
627
630
|
else
|
628
|
-
# We are performing a `record_destroy
|
629
|
-
#
|
631
|
+
# We are either performing a `record_destroy` or a
|
632
|
+
# `record_update(is_touch: true)`.
|
630
633
|
@record.attribute_in_database(attr_name.to_s)
|
631
634
|
end
|
632
635
|
else
|
@@ -635,7 +638,7 @@ module PaperTrail
|
|
635
638
|
end
|
636
639
|
|
637
640
|
# Rails 5.1 changed the API of `ActiveRecord::Dirty`. See
|
638
|
-
# https://github.com/
|
641
|
+
# https://github.com/paper-trail-gem/paper_trail/pull/899
|
639
642
|
#
|
640
643
|
# @api private
|
641
644
|
def changed_in_latest_version
|
@@ -647,7 +650,7 @@ module PaperTrail
|
|
647
650
|
end
|
648
651
|
|
649
652
|
# Rails 5.1 changed the API of `ActiveRecord::Dirty`. See
|
650
|
-
# https://github.com/
|
653
|
+
# https://github.com/paper-trail-gem/paper_trail/pull/899
|
651
654
|
#
|
652
655
|
# @api private
|
653
656
|
def changes_in_latest_version
|
@@ -23,7 +23,7 @@ module PaperTrail
|
|
23
23
|
and Bicycle are both Vehicles and the FK for both is owner_id)
|
24
24
|
|
25
25
|
If you'd like to help fix this error, please read
|
26
|
-
https://github.com/
|
26
|
+
https://github.com/paper-trail-gem/paper_trail/issues/594
|
27
27
|
and see spec/models/person_spec.rb
|
28
28
|
STR
|
29
29
|
|
@@ -38,7 +38,7 @@ module PaperTrail
|
|
38
38
|
column. The old implementation was inaccurate, returning more records
|
39
39
|
than you wanted. This feature was deprecated in 7.1.0 and removed in
|
40
40
|
8.0.0. The json and jsonb datatypes are still supported. See the
|
41
|
-
discussion at https://github.com/
|
41
|
+
discussion at https://github.com/paper-trail-gem/paper_trail/issues/803
|
42
42
|
STR
|
43
43
|
end
|
44
44
|
end
|
@@ -30,7 +30,7 @@ module PaperTrail
|
|
30
30
|
column. The old implementation was inaccurate, returning more records
|
31
31
|
than you wanted. This feature was deprecated in 8.1.0 and removed in
|
32
32
|
9.0.0. The json and jsonb datatypes are still supported. See
|
33
|
-
discussion at https://github.com/
|
33
|
+
discussion at https://github.com/paper-trail-gem/paper_trail/pull/997
|
34
34
|
STR
|
35
35
|
end
|
36
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.
|
4
|
+
version: 9.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Stewart
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-05-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -265,7 +265,7 @@ files:
|
|
265
265
|
- lib/paper_trail/version_association_concern.rb
|
266
266
|
- lib/paper_trail/version_concern.rb
|
267
267
|
- lib/paper_trail/version_number.rb
|
268
|
-
homepage: https://github.com/
|
268
|
+
homepage: https://github.com/paper-trail-gem/paper_trail
|
269
269
|
licenses:
|
270
270
|
- MIT
|
271
271
|
metadata: {}
|