paper_trail 8.0.0 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91bf6fabed9a524ca3251a32df08bf75daaf8e59
4
- data.tar.gz: 98c9208fcb6946ce58943ff3188ddee60f90a0de
3
+ metadata.gz: 5cbdc5e0fcbf8cc19260c5e551610909262bff20
4
+ data.tar.gz: 827f66aa4dd73c0dc8e655c4b0f8bbaea55dd001
5
5
  SHA512:
6
- metadata.gz: f75fd7f32568e15f48194cbd099152f75d0e38bd3e3e5f173c16f20919ad3766f9ccfebb69203558946abcd48d1da017a80749c1c957093af589478fa187b2cb
7
- data.tar.gz: b4916a9fae7ce82d73d98baefb6d63d41482c0e7dc090751b2ddf7543876a070782c16a233f1b89617932ec1fb92d9810995b67ab4196d7bff94ecc471e2f912
6
+ metadata.gz: f306a77a02fe166550ddd0d62ded99324bb3e21108bc479f976b23d08200585a3d5dc049ec0c9f44594cc1f9fa28cd1b8da4a29987f6a49be6aed961c4c67e2f
7
+ data.tar.gz: 45697214fc6d236edc14b2090dc111f58a90c628be74c59c5097eb3e677fb0c6052ceae2212d7bdc814016c921d4811d4400fb146b5999aefc296a53df38b6bf
@@ -1,3 +1,4 @@
1
+ require "active_support"
1
2
  require "request_store"
2
3
  require "paper_trail/cleaner"
3
4
  require "paper_trail/config"
@@ -13,6 +14,18 @@ require "paper_trail/serializers/yaml"
13
14
  # An ActiveRecord extension that tracks changes to your models, for auditing or
14
15
  # versioning.
15
16
  module PaperTrail
17
+ E_RAILS_NOT_LOADED = <<-EOS.squish.freeze
18
+ PaperTrail has been loaded too early, before rails is loaded. This can
19
+ happen when another gem defines the ::Rails namespace, then PT is loaded,
20
+ all before rails is loaded. You may want to reorder your Gemfile, or defer
21
+ the loading of PT by using `require: false` and a manual require elsewhere.
22
+ EOS
23
+ E_TIMESTAMP_FIELD_CONFIG = <<-EOS.squish.freeze
24
+ PaperTrail.timestamp_field= has been removed, without replacement. It is no
25
+ longer configurable. The timestamp field in the versions table must now be
26
+ named created_at.
27
+ EOS
28
+
16
29
  extend PaperTrail::Cleaner
17
30
 
18
31
  class << self
@@ -72,11 +85,7 @@ module PaperTrail
72
85
  # Set the field which records when a version was created.
73
86
  # @api public
74
87
  def timestamp_field=(_field_name)
75
- raise(
76
- "PaperTrail.timestamp_field= has been removed, without replacement. " \
77
- "It is no longer configurable. The timestamp field in the versions table " \
78
- "must now be named created_at."
79
- )
88
+ raise(E_TIMESTAMP_FIELD_CONFIG)
80
89
  end
81
90
 
82
91
  # Sets who is responsible for any changes that occur. You would normally use
@@ -187,8 +196,14 @@ ActiveSupport.on_load(:active_record) do
187
196
  end
188
197
 
189
198
  # Require frameworks
190
- if defined?(::Rails) && ActiveRecord::VERSION::STRING >= "3.2"
191
- require "paper_trail/frameworks/rails"
199
+ if defined?(::Rails)
200
+ # Rails module is sometimes defined by gems like rails-html-sanitizer
201
+ # so we check for presence of Rails.application.
202
+ if defined?(::Rails.application)
203
+ require "paper_trail/frameworks/rails"
204
+ else
205
+ ::Kernel.warn(::PaperTrail::E_RAILS_NOT_LOADED)
206
+ end
192
207
  else
193
208
  require "paper_trail/frameworks/active_record"
194
209
  end
@@ -59,7 +59,7 @@ module PaperTrail
59
59
 
60
60
  # Adds a callback that records a version after an "update" event.
61
61
  def on_update
62
- @model_class.before_save(on: :update) { |r|
62
+ @model_class.before_save { |r|
63
63
  r.paper_trail.reset_timestamp_attrs_for_update_if_needed
64
64
  }
65
65
  @model_class.after_update { |r|
@@ -333,13 +333,7 @@ module PaperTrail
333
333
  def reset_timestamp_attrs_for_update_if_needed
334
334
  return if live?
335
335
  @record.send(:timestamp_attributes_for_update_in_model).each do |column|
336
- # ActiveRecord 4.2 deprecated `reset_column!` in favor of
337
- # `restore_column!`.
338
- if @record.respond_to?("restore_#{column}!")
339
- @record.send("restore_#{column}!")
340
- else
341
- @record.send("reset_#{column}!")
342
- end
336
+ @record.send("restore_#{column}!")
343
337
  end
344
338
  end
345
339
 
@@ -4,6 +4,13 @@ module PaperTrail
4
4
  module Serializers
5
5
  # The default serializer for, e.g. `versions.object`.
6
6
  module YAML
7
+ E_WHERE_OBJ_CHANGES = <<-STR.squish.freeze
8
+ where_object_changes has a known issue. When reading YAML from a text
9
+ column, it may return more records than expected. Instead of a warning,
10
+ this method may raise an error in the future. Please join the discussion
11
+ at https://github.com/airblade/paper_trail/pull/997
12
+ STR
13
+
7
14
  extend self # makes all instance methods become module methods as well
8
15
 
9
16
  def load(string)
@@ -23,6 +30,8 @@ module PaperTrail
23
30
  # Returns a SQL LIKE condition to be used to match the given field and
24
31
  # value in the serialized `object_changes`.
25
32
  def where_object_changes_condition(arel_field, field, value)
33
+ ::ActiveSupport::Deprecation.warn(E_WHERE_OBJ_CHANGES)
34
+
26
35
  # Need to check first (before) and secondary (after) fields
27
36
  m1 = "%\n#{field}:\n- #{value}\n%"
28
37
  m2 = "%\n#{field}:\n-%\n- #{value}\n%"
@@ -7,7 +7,7 @@ module PaperTrail
7
7
  module VERSION
8
8
  MAJOR = 8
9
9
  MINOR = 0
10
- TINY = 0
10
+ TINY = 1
11
11
  PRE = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
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: 8.0.0
4
+ version: 8.0.1
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: 2017-10-05 00:00:00.000000000 Z
13
+ date: 2017-10-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -52,216 +52,196 @@ dependencies:
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '2.1'
55
+ version: '2.2'
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '2.1'
62
+ version: '2.2'
63
63
  - !ruby/object:Gem::Dependency
64
- name: rake
64
+ name: database_cleaner
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '12.0'
69
+ version: '1.6'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '12.0'
76
+ version: '1.6'
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: ffaker
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '2.5'
83
+ version: '2.7'
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '2.5'
91
- - !ruby/object:Gem::Dependency
92
- name: railties
93
- requirement: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '4.2'
98
- - - "<"
99
- - !ruby/object:Gem::Version
100
- version: '5.2'
101
- type: :development
102
- prerelease: false
103
- version_requirements: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- version: '4.2'
108
- - - "<"
109
- - !ruby/object:Gem::Version
110
- version: '5.2'
90
+ version: '2.7'
111
91
  - !ruby/object:Gem::Dependency
112
- name: rack-test
92
+ name: generator_spec
113
93
  requirement: !ruby/object:Gem::Requirement
114
94
  requirements:
115
95
  - - "~>"
116
96
  - !ruby/object:Gem::Version
117
- version: 0.6.3
97
+ version: 0.9.4
118
98
  type: :development
119
99
  prerelease: false
120
100
  version_requirements: !ruby/object:Gem::Requirement
121
101
  requirements:
122
102
  - - "~>"
123
103
  - !ruby/object:Gem::Version
124
- version: 0.6.3
104
+ version: 0.9.4
125
105
  - !ruby/object:Gem::Dependency
126
- name: rspec-rails
106
+ name: mysql2
127
107
  requirement: !ruby/object:Gem::Requirement
128
108
  requirements:
129
109
  - - "~>"
130
110
  - !ruby/object:Gem::Version
131
- version: '3.5'
111
+ version: 0.4.9
132
112
  type: :development
133
113
  prerelease: false
134
114
  version_requirements: !ruby/object:Gem::Requirement
135
115
  requirements:
136
116
  - - "~>"
137
117
  - !ruby/object:Gem::Version
138
- version: '3.5'
118
+ version: 0.4.9
139
119
  - !ruby/object:Gem::Dependency
140
- name: generator_spec
120
+ name: pg
141
121
  requirement: !ruby/object:Gem::Requirement
142
122
  requirements:
143
123
  - - "~>"
144
124
  - !ruby/object:Gem::Version
145
- version: 0.9.3
125
+ version: 0.21.0
146
126
  type: :development
147
127
  prerelease: false
148
128
  version_requirements: !ruby/object:Gem::Requirement
149
129
  requirements:
150
130
  - - "~>"
151
131
  - !ruby/object:Gem::Version
152
- version: 0.9.3
132
+ version: 0.21.0
153
133
  - !ruby/object:Gem::Dependency
154
- name: database_cleaner
134
+ name: pry-byebug
155
135
  requirement: !ruby/object:Gem::Requirement
156
136
  requirements:
157
137
  - - "~>"
158
138
  - !ruby/object:Gem::Version
159
- version: '1.2'
139
+ version: '3.5'
160
140
  type: :development
161
141
  prerelease: false
162
142
  version_requirements: !ruby/object:Gem::Requirement
163
143
  requirements:
164
144
  - - "~>"
165
145
  - !ruby/object:Gem::Version
166
- version: '1.2'
146
+ version: '3.5'
167
147
  - !ruby/object:Gem::Dependency
168
- name: pry-byebug
148
+ name: rack-test
169
149
  requirement: !ruby/object:Gem::Requirement
170
150
  requirements:
171
151
  - - "~>"
172
152
  - !ruby/object:Gem::Version
173
- version: '3.4'
153
+ version: 0.6.3
174
154
  type: :development
175
155
  prerelease: false
176
156
  version_requirements: !ruby/object:Gem::Requirement
177
157
  requirements:
178
158
  - - "~>"
179
159
  - !ruby/object:Gem::Version
180
- version: '3.4'
160
+ version: 0.6.3
181
161
  - !ruby/object:Gem::Dependency
182
- name: rubocop
162
+ name: rake
183
163
  requirement: !ruby/object:Gem::Requirement
184
164
  requirements:
185
- - - '='
165
+ - - "~>"
186
166
  - !ruby/object:Gem::Version
187
- version: 0.50.0
167
+ version: '12.1'
188
168
  type: :development
189
169
  prerelease: false
190
170
  version_requirements: !ruby/object:Gem::Requirement
191
171
  requirements:
192
- - - '='
172
+ - - "~>"
193
173
  - !ruby/object:Gem::Version
194
- version: 0.50.0
174
+ version: '12.1'
195
175
  - !ruby/object:Gem::Dependency
196
- name: rubocop-rspec
176
+ name: rspec-rails
197
177
  requirement: !ruby/object:Gem::Requirement
198
178
  requirements:
199
179
  - - "~>"
200
180
  - !ruby/object:Gem::Version
201
- version: 1.17.0
181
+ version: 3.7.1
202
182
  type: :development
203
183
  prerelease: false
204
184
  version_requirements: !ruby/object:Gem::Requirement
205
185
  requirements:
206
186
  - - "~>"
207
187
  - !ruby/object:Gem::Version
208
- version: 1.17.0
188
+ version: 3.7.1
209
189
  - !ruby/object:Gem::Dependency
210
- name: timecop
190
+ name: rubocop
211
191
  requirement: !ruby/object:Gem::Requirement
212
192
  requirements:
213
- - - "~>"
193
+ - - '='
214
194
  - !ruby/object:Gem::Version
215
- version: 0.8.0
195
+ version: 0.50.0
216
196
  type: :development
217
197
  prerelease: false
218
198
  version_requirements: !ruby/object:Gem::Requirement
219
199
  requirements:
220
- - - "~>"
200
+ - - '='
221
201
  - !ruby/object:Gem::Version
222
- version: 0.8.0
202
+ version: 0.50.0
223
203
  - !ruby/object:Gem::Dependency
224
- name: sqlite3
204
+ name: rubocop-rspec
225
205
  requirement: !ruby/object:Gem::Requirement
226
206
  requirements:
227
207
  - - "~>"
228
208
  - !ruby/object:Gem::Version
229
- version: '1.2'
209
+ version: 1.18.0
230
210
  type: :development
231
211
  prerelease: false
232
212
  version_requirements: !ruby/object:Gem::Requirement
233
213
  requirements:
234
214
  - - "~>"
235
215
  - !ruby/object:Gem::Version
236
- version: '1.2'
216
+ version: 1.18.0
237
217
  - !ruby/object:Gem::Dependency
238
- name: pg
218
+ name: sqlite3
239
219
  requirement: !ruby/object:Gem::Requirement
240
220
  requirements:
241
221
  - - "~>"
242
222
  - !ruby/object:Gem::Version
243
- version: 0.19.0
223
+ version: '1.3'
244
224
  type: :development
245
225
  prerelease: false
246
226
  version_requirements: !ruby/object:Gem::Requirement
247
227
  requirements:
248
228
  - - "~>"
249
229
  - !ruby/object:Gem::Version
250
- version: 0.19.0
230
+ version: '1.3'
251
231
  - !ruby/object:Gem::Dependency
252
- name: mysql2
232
+ name: timecop
253
233
  requirement: !ruby/object:Gem::Requirement
254
234
  requirements:
255
235
  - - "~>"
256
236
  - !ruby/object:Gem::Version
257
- version: 0.4.2
237
+ version: 0.9.1
258
238
  type: :development
259
239
  prerelease: false
260
240
  version_requirements: !ruby/object:Gem::Requirement
261
241
  requirements:
262
242
  - - "~>"
263
243
  - !ruby/object:Gem::Version
264
- version: 0.4.2
244
+ version: 0.9.1
265
245
  description: |
266
246
  Track changes to your models, for auditing or versioning. See how a model looked
267
247
  at any stage in its lifecycle, revert it to any version, or restore it after it
@@ -331,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
311
  version: 1.3.6
332
312
  requirements: []
333
313
  rubyforge_project:
334
- rubygems_version: 2.6.13
314
+ rubygems_version: 2.6.14
335
315
  signing_key:
336
316
  specification_version: 4
337
317
  summary: Track changes to your models.