audited 5.3.1 → 5.3.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.
Potentially problematic release.
This version of audited might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/audited/auditor.rb +9 -7
- data/lib/audited/version.rb +1 -1
- data/spec/audited/auditor_spec.rb +22 -6
- data/spec/support/active_record/models.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9441d78ecdc47f146411573dbbba291449a94d062e2e564be52ff58548a2c25
|
4
|
+
data.tar.gz: e2843b1bfe94e4a19aa6666a98c01d23fd165240f96d2c602d5291383b68f4a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbee8a19b3da64248a2d2ea58bdac95f94431b4e57545ceae25897b50470a3adf7bc9b7497da58a7e85e466502d2baa3c0d9e9e96e070b2f48b8a0ebe506cd0d
|
7
|
+
data.tar.gz: e0093f598ceec9caade9d14c9fdba938e8ba92b3355bc164ba9587b1863230681586071ac5864ede9aaf361be58bdad38e08742a9f06e1093e89422c0a04e4ea
|
data/CHANGELOG.md
CHANGED
data/lib/audited/auditor.rb
CHANGED
@@ -233,12 +233,12 @@ module Audited
|
|
233
233
|
|
234
234
|
def audited_changes(for_touch: false)
|
235
235
|
all_changes = if for_touch
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
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
|
-
|
255
|
+
audits.last.audited_changes[k].to_json == v[1].to_json
|
254
256
|
end
|
255
257
|
end
|
256
258
|
|
data/lib/audited/version.rb
CHANGED
@@ -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
|
-
uncovered = ActiveRecord::VERSION::MAJOR < 6 ?
|
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(
|
238
|
-
expect(user.audits.last.audited_changes).not_to have_key(
|
239
|
-
expect(user.audits.last.audited_changes).not_to have_key(
|
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: [{
|
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
|
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.
|
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-
|
16
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activerecord
|