audited 5.3.1 → 5.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of audited might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 051f76b7a9cfbc91222643f2e0ddaa7738d2e446c00ec079dcf0b5d64d7146d3
4
- data.tar.gz: 70ef8ed6c1473ca9d2ac21dc444ae66c0b8d42280e5a3c6bf4d1fe46c07f0e60
3
+ metadata.gz: c9441d78ecdc47f146411573dbbba291449a94d062e2e564be52ff58548a2c25
4
+ data.tar.gz: e2843b1bfe94e4a19aa6666a98c01d23fd165240f96d2c602d5291383b68f4a1
5
5
  SHA512:
6
- metadata.gz: e085b0764b5feb96dc88cb5db4361f07148550368bde350a45fe21aba47ed80bfa38bb5683437bf3ad7cd983d7dbfe5f4980a80a7da0f1bf76dabea037323b58
7
- data.tar.gz: d55bbe1f1f139efd63ac97281d954bfac440b091e292ad57b23668a456f4e389f4401c9a6e6e4ebb9627d4556a9460cb94d2d71c0f0f2f5174b0e62cb2c10968
6
+ metadata.gz: fbee8a19b3da64248a2d2ea58bdac95f94431b4e57545ceae25897b50470a3adf7bc9b7497da58a7e85e466502d2baa3c0d9e9e96e070b2f48b8a0ebe506cd0d
7
+ data.tar.gz: e0093f598ceec9caade9d14c9fdba938e8ba92b3355bc164ba9587b1863230681586071ac5864ede9aaf361be58bdad38e08742a9f06e1093e89422c0a04e4ea
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Audited ChangeLog
2
2
 
3
+ ## 5.3.2 (2023-02-22)
4
+
5
+ - Touch audit bug fixes - @mcyoung
6
+ [#662](https://github.com/collectiveidea/audited/pull/662)
7
+
3
8
  ## 5.3.1 (2023-02-21)
4
9
 
5
10
  - Ensure touch support doesn't cause double audits - @mcyoung
@@ -233,12 +233,12 @@ module Audited
233
233
 
234
234
  def audited_changes(for_touch: false)
235
235
  all_changes = if for_touch
236
- previous_changes
237
- elsif respond_to?(:changes_to_save)
238
- changes_to_save
239
- else
240
- changes
241
- end
236
+ previous_changes
237
+ elsif respond_to?(:changes_to_save)
238
+ changes_to_save
239
+ else
240
+ changes
241
+ end
242
242
 
243
243
  filtered_changes = \
244
244
  if audited_options[:only].present?
@@ -249,8 +249,10 @@ module Audited
249
249
 
250
250
  if for_touch
251
251
  filtered_changes.reject! do |k, v|
252
+ next unless audits.present?
253
+
252
254
  audits.last.audited_changes[k].to_json == v.to_json ||
253
- audits.last.audited_changes[k].to_json == v[1].to_json
255
+ audits.last.audited_changes[k].to_json == v[1].to_json
254
256
  end
255
257
  end
256
258
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audited
4
- VERSION = "5.3.1"
4
+ VERSION = "5.3.2"
5
5
  end
@@ -1,8 +1,8 @@
1
1
  require "spec_helper"
2
2
 
3
3
  # not testing proxy_respond_to? hack / 2 methods / deprecation of `version`
4
- # also, an additional 5 around `after_touch` for Versions before 6.
5
- uncovered = ActiveRecord::VERSION::MAJOR < 6 ? 14 : 9
4
+ # also, an additional 6 around `after_touch` for Versions before 6.
5
+ uncovered = (ActiveRecord::VERSION::MAJOR < 6) ? 15 : 9
6
6
  SingleCov.covered! uncovered: uncovered
7
7
 
8
8
  class ConditionalPrivateCompany < ::ActiveRecord::Base
@@ -234,9 +234,9 @@ describe Audited::Auditor do
234
234
  # If we haven't changed any attrs from 'redacted' list, audit should not contain these keys
235
235
  user.name = "new name"
236
236
  user.save!
237
- expect(user.audits.last.audited_changes).to have_key('name')
238
- expect(user.audits.last.audited_changes).not_to have_key('password')
239
- expect(user.audits.last.audited_changes).not_to have_key('ssn')
237
+ expect(user.audits.last.audited_changes).to have_key("name")
238
+ expect(user.audits.last.audited_changes).not_to have_key("password")
239
+ expect(user.audits.last.audited_changes).not_to have_key("ssn")
240
240
  end
241
241
 
242
242
  it "should redact columns in 'redacted' column with custom option" do
@@ -462,8 +462,24 @@ describe Audited::Auditor do
462
462
  }.to_not change(Audited::Audit, :count)
463
463
  end
464
464
 
465
+ it "should store an audit if touch is the only audit" do
466
+ on_touch = Models::ActiveRecord::OnTouchOnly.create(name: "Bart")
467
+ expect {
468
+ on_touch.update(name: "NotBart")
469
+ }.to_not change(Audited::Audit, :count)
470
+ expect {
471
+ on_touch.touch(:suspended_at)
472
+ }.to change(on_touch.audits, :count).from(0).to(1)
473
+
474
+ @user.audits.destroy_all
475
+ expect(@user.audits).to be_empty
476
+ expect {
477
+ @user.touch(:suspended_at)
478
+ }.to change(@user.audits, :count).from(0).to(1)
479
+ end
480
+
465
481
  context "don't double audit" do
466
- let(:user) { Models::ActiveRecord::Owner.create(name: "OwnerUser", suspended_at: 1.month.ago, companies_attributes: [{ name: "OwnedCompany" }]) }
482
+ let(:user) { Models::ActiveRecord::Owner.create(name: "OwnerUser", suspended_at: 1.month.ago, companies_attributes: [{name: "OwnedCompany"}]) }
467
483
  let(:company) { user.companies.first }
468
484
 
469
485
  it "should only create 1 (create) audit for object" do
@@ -161,5 +161,10 @@ module Models
161
161
  self.table_name = "companies"
162
162
  audited on: [:create, :update]
163
163
  end
164
+
165
+ class OnTouchOnly < ::ActiveRecord::Base
166
+ self.table_name = "users"
167
+ audited on: [:touch]
168
+ end
164
169
  end
165
170
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audited
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.1
4
+ version: 5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-02-21 00:00:00.000000000 Z
16
+ date: 2023-02-22 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord