paper_trail 9.0.0 → 9.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
  SHA256:
3
- metadata.gz: 24616bf1e1df70302e7417a24d60141dc2a0d20f1c6e8ac3690dbd4abf890a82
4
- data.tar.gz: 8f0ea37c0b65a0c15bfbf4096db430e81d848952f6d42ecbc09d5028fa042d3e
3
+ metadata.gz: 1c8b21b88ed51a36003e6df11297955cfba569f71d3c6de6be11715a94ec63c9
4
+ data.tar.gz: 11b1b625dd80e75f3218a047d9caf69ead79e18bf79dc7f7b5e597b0f4b7f7a4
5
5
  SHA512:
6
- metadata.gz: 109af4466c2f6a61b42633bb94e46909203252757d7864250dd8e62cddfe82ef317419fc5ad8f784eecb453af387a02242b643b58b8eadd5778ce1e64c4b56a3
7
- data.tar.gz: b840ca06183ff5411b0dcc493c8bdbc8abaa94060d8dfccaf1b0cbd0bbf69cd4bda4c2a98e3bd406d4760317e9949c89e306bd7b54e676237b162f3721f30497
6
+ metadata.gz: 6e024e2ad10466f53e07edc2d0683de403034cdedf49b2f6440c3fe8c59b37f90a46ec1f6ddcf1412b21dfa4c0369e3caefe701eb05c4c30e9701a2c6666d1ff
7
+ data.tar.gz: 6c98b6f10cc6a4e4e0b8d0b516d3d89eec54243624a544b4b7bea7963400b38c944bdbe2d438ead507bc43f57b71fada18b7fd0f5caa51338c6c357c59e66345
@@ -16,7 +16,7 @@ module PaperTrail
16
16
  "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
17
17
  ].freeze
18
18
 
19
- source_root File.expand_path("../templates", __FILE__)
19
+ source_root File.expand_path("templates", __dir__)
20
20
  class_option(
21
21
  :with_changes,
22
22
  type: :boolean,
data/lib/paper_trail.rb CHANGED
@@ -121,7 +121,8 @@ module PaperTrail
121
121
  # word "request" right there in your application code will remind you that
122
122
  # these variables only affect the current request, not all threads.
123
123
  #
124
- # Given a block, temporarily sets the given `options` and execute the block.
124
+ # Given a block, temporarily sets the given `options`, executes the block,
125
+ # and returns the value of the block.
125
126
  #
126
127
  # Without a block, this currently just returns `PaperTrail::Request`.
127
128
  # However, please do not use `PaperTrail::Request` directly. Currently,
@@ -135,7 +136,6 @@ module PaperTrail
135
136
  Request
136
137
  else
137
138
  Request.with(options, &block)
138
- nil
139
139
  end
140
140
  end
141
141
 
@@ -4,8 +4,10 @@ module PaperTrail
4
4
  # Represents the "paper trail" for a single record.
5
5
  class RecordTrail
6
6
  DPR_TOUCH_WITH_VERSION = <<-STR.squish.freeze
7
- my_model_instance.paper_trail.touch_with_version is deprecated,
8
- please use my_model_instance.touch
7
+ my_model.paper_trail.touch_with_version is deprecated, please use
8
+ my_model.paper_trail.save_with_version, which is slightly different. It's
9
+ a save, not a touch, so make sure you understand the difference by reading
10
+ the ActiveRecord documentation for both.
9
11
  STR
10
12
  DPR_WHODUNNIT = <<-STR.squish.freeze
11
13
  my_model_instance.paper_trail.whodunnit('John') is deprecated,
@@ -508,6 +510,26 @@ module PaperTrail
508
510
  record_update(force: true, in_after_callback: false)
509
511
  end
510
512
 
513
+ # Save, and create a version record regardless of options such as `:on`,
514
+ # `:if`, or `:unless`.
515
+ #
516
+ # Arguments are passed to `save`.
517
+ #
518
+ # This is an "update" event. That is, we record the same data we would in
519
+ # the case of a normal AR `update`.
520
+ #
521
+ # In older versions of PaperTrail, a method named `touch_with_version` was
522
+ # used for this purpose. `save_with_version` is not exactly the same.
523
+ # First, the arguments are different. It passes all arguments to `save`.
524
+ # Second, it doesn't set any timestamp attributes prior to the `save` the
525
+ # way `touch_with_version` did.
526
+ def save_with_version(*args)
527
+ ::PaperTrail.request(enabled: false) do
528
+ @record.save(*args)
529
+ end
530
+ record_update(force: true, in_after_callback: false)
531
+ end
532
+
511
533
  # Like the `update_column` method from `ActiveRecord::Persistence`, but also
512
534
  # creates a version to record those changes.
513
535
  # @api public
@@ -648,7 +670,7 @@ module PaperTrail
648
670
 
649
671
  def log_version_errors(version, action)
650
672
  version.logger&.warn(
651
- "Unable to create version for #{action} of #{@record.class.name}" +
673
+ "Unable to create version for #{action} of #{@record.class.name}" \
652
674
  "##{@record.id}: " + version.errors.full_messages.join(", ")
653
675
  )
654
676
  end
@@ -9,7 +9,7 @@ module PaperTrail
9
9
  module VERSION
10
10
  MAJOR = 9
11
11
  MINOR = 0
12
- TINY = 0
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  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: 9.0.0
4
+ version: 9.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: 2018-03-27 00:00:00.000000000 Z
13
+ date: 2018-04-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -66,28 +66,28 @@ dependencies:
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '9.1'
69
+ version: '10.0'
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: '9.1'
76
+ version: '10.0'
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.7'
83
+ version: '2.8'
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.7'
90
+ version: '2.8'
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: generator_spec
93
93
  requirement: !ruby/object:Gem::Requirement
@@ -130,26 +130,6 @@ dependencies:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
132
  version: 0.21.0
133
- - !ruby/object:Gem::Dependency
134
- name: rack-test
135
- requirement: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: 0.6.3
140
- - - "<"
141
- - !ruby/object:Gem::Version
142
- version: '0.9'
143
- type: :development
144
- prerelease: false
145
- version_requirements: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: 0.6.3
150
- - - "<"
151
- - !ruby/object:Gem::Version
152
- version: '0.9'
153
133
  - !ruby/object:Gem::Dependency
154
134
  name: rake
155
135
  requirement: !ruby/object:Gem::Requirement
@@ -184,28 +164,28 @@ dependencies:
184
164
  requirements:
185
165
  - - "~>"
186
166
  - !ruby/object:Gem::Version
187
- version: 0.51.0
167
+ version: 0.54.0
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.51.0
174
+ version: 0.54.0
195
175
  - !ruby/object:Gem::Dependency
196
176
  name: rubocop-rspec
197
177
  requirement: !ruby/object:Gem::Requirement
198
178
  requirements:
199
179
  - - "~>"
200
180
  - !ruby/object:Gem::Version
201
- version: 1.19.0
181
+ version: 1.24.0
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.19.0
188
+ version: 1.24.0
209
189
  - !ruby/object:Gem::Dependency
210
190
  name: sqlite3
211
191
  requirement: !ruby/object:Gem::Requirement