audited 5.3.3 → 5.8.0
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/Appraisals +33 -20
- data/CHANGELOG.md +52 -1
- data/README.md +11 -3
- data/Rakefile +1 -3
- data/audited.gemspec +38 -0
- data/lib/audited/audit.rb +5 -1
- data/lib/audited/auditor.rb +49 -14
- data/lib/audited/version.rb +1 -1
- data/lib/audited.rb +11 -4
- data/lib/generators/audited/migration.rb +1 -1
- metadata +26 -59
- data/.github/workflows/buildlight.yml +0 -15
- data/.github/workflows/ci.yml +0 -134
- data/.gitignore +0 -17
- data/.standard.yml +0 -5
- data/.yardopts +0 -3
- data/gemfiles/rails50.gemfile +0 -11
- data/gemfiles/rails51.gemfile +0 -11
- data/gemfiles/rails52.gemfile +0 -11
- data/gemfiles/rails60.gemfile +0 -10
- data/gemfiles/rails61.gemfile +0 -10
- data/gemfiles/rails70.gemfile +0 -10
- data/spec/audited/audit_spec.rb +0 -357
- data/spec/audited/auditor_spec.rb +0 -1227
- data/spec/audited/rspec_matchers_spec.rb +0 -69
- data/spec/audited/sweeper_spec.rb +0 -133
- data/spec/audited_spec.rb +0 -14
- data/spec/audited_spec_helpers.rb +0 -32
- data/spec/rails_app/app/assets/config/manifest.js +0 -2
- data/spec/rails_app/config/application.rb +0 -19
- data/spec/rails_app/config/database.yml +0 -26
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/test.rb +0 -52
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/inflections.rb +0 -2
- data/spec/rails_app/config/initializers/secret_token.rb +0 -3
- data/spec/rails_app/config/routes.rb +0 -3
- data/spec/spec_helper.rb +0 -24
- data/spec/support/active_record/models.rb +0 -170
- data/spec/support/active_record/postgres/1_change_audited_changes_type_to_json.rb +0 -11
- data/spec/support/active_record/postgres/2_change_audited_changes_type_to_jsonb.rb +0 -11
- data/spec/support/active_record/schema.rb +0 -90
- data/test/db/version_1.rb +0 -17
- data/test/db/version_2.rb +0 -18
- data/test/db/version_3.rb +0 -18
- data/test/db/version_4.rb +0 -19
- data/test/db/version_5.rb +0 -17
- data/test/db/version_6.rb +0 -19
- data/test/install_generator_test.rb +0 -62
- data/test/test_helper.rb +0 -18
- data/test/upgrade_generator_test.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0bfd7a5ca6d490f0462b5605cca4406ee60edbc1684953a3262f1395662b1a4
|
4
|
+
data.tar.gz: 4bf6e8845875c22900eb94d9dc0cfd73ddb0f065e379b59648bbd1555f3a0db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce188b4c71689ef96dce51e1affb292dc5f98c8fee625241e6d929ed361887bfa4643c975ac7ce031eddff2956dcfbc5bf4e630f58fa9f5a4bb46e6f06d05d9e
|
7
|
+
data.tar.gz: 305b28ac6501b9bc159fdab34fbd013202e797669072721ce7cb765ad7f7a779ae9893e3ad1eab634d6a7be785c658c4a7b7e8ee1baceb48683ad6a1e1f67b78
|
data/Appraisals
CHANGED
@@ -1,47 +1,60 @@
|
|
1
1
|
# Include DB adapters matching the version requirements in
|
2
2
|
# rails/activerecord/lib/active_record/connection_adapters/*adapter.rb
|
3
3
|
|
4
|
-
appraise "rails50" do
|
5
|
-
gem "rails", "~> 5.0.0"
|
6
|
-
gem "mysql2", ">= 0.3.18", "< 0.6.0"
|
7
|
-
gem "pg", ">= 0.18", "< 2.0"
|
8
|
-
gem "sqlite3", "~> 1.3.6"
|
9
|
-
gem "psych", "~> 3.1"
|
10
|
-
end
|
11
|
-
|
12
|
-
appraise "rails51" do
|
13
|
-
gem "rails", "~> 5.1.4"
|
14
|
-
gem "mysql2", ">= 0.3.18", "< 0.6.0"
|
15
|
-
gem "pg", ">= 0.18", "< 2.0"
|
16
|
-
gem "sqlite3", "~> 1.3.6"
|
17
|
-
gem "psych", "~> 3.1"
|
18
|
-
end
|
19
|
-
|
20
4
|
appraise "rails52" do
|
21
|
-
gem "rails", "
|
5
|
+
gem "rails", "~> 5.2.8"
|
22
6
|
gem "mysql2", ">= 0.4.4", "< 0.6.0"
|
23
7
|
gem "pg", ">= 0.18", "< 2.0"
|
24
8
|
gem "sqlite3", "~> 1.3.6"
|
25
9
|
gem "psych", "~> 3.1"
|
10
|
+
gem "loofah", "2.20.0"
|
26
11
|
end
|
27
12
|
|
28
13
|
appraise "rails60" do
|
29
|
-
gem "rails", "
|
14
|
+
gem "rails", "~> 6.0.6"
|
30
15
|
gem "mysql2", ">= 0.4.4"
|
31
16
|
gem "pg", ">= 0.18", "< 2.0"
|
32
17
|
gem "sqlite3", "~> 1.4"
|
33
18
|
end
|
34
19
|
|
35
20
|
appraise "rails61" do
|
36
|
-
gem "rails", "
|
21
|
+
gem "rails", "~> 6.1.7"
|
37
22
|
gem "mysql2", ">= 0.4.4"
|
38
23
|
gem "pg", ">= 1.1", "< 2.0"
|
39
24
|
gem "sqlite3", "~> 1.4"
|
40
25
|
end
|
41
26
|
|
42
27
|
appraise "rails70" do
|
43
|
-
gem "rails", "
|
28
|
+
gem "rails", "~> 7.0.8"
|
44
29
|
gem "mysql2", ">= 0.4.4"
|
45
30
|
gem "pg", ">= 1.1"
|
31
|
+
gem "sqlite3", "~> 1.4"
|
32
|
+
end
|
33
|
+
|
34
|
+
appraise "rails71" do
|
35
|
+
gem "rails", "~> 7.1.3"
|
36
|
+
gem "mysql2", ">= 0.4.4"
|
37
|
+
gem "pg", ">= 1.1"
|
38
|
+
gem "sqlite3", "~> 1.4"
|
39
|
+
end
|
40
|
+
|
41
|
+
appraise "rails72" do
|
42
|
+
gem "rails", "~> 7.2.0"
|
43
|
+
gem "mysql2", "~> 0.5"
|
44
|
+
gem "pg", "~> 1.1"
|
46
45
|
gem "sqlite3", ">= 1.4"
|
47
46
|
end
|
47
|
+
|
48
|
+
appraise "rails80" do
|
49
|
+
gem "rails", "~> 8.0.0"
|
50
|
+
gem "mysql2", "~> 0.5"
|
51
|
+
gem "pg", "~> 1.1"
|
52
|
+
gem "sqlite3", ">= 1.4"
|
53
|
+
end
|
54
|
+
|
55
|
+
appraise "rails_main" do
|
56
|
+
gem "rails", github: "rails/rails", branch: "main"
|
57
|
+
gem "mysql2", "~> 0.5"
|
58
|
+
gem "pg", "~> 1.1"
|
59
|
+
gem "sqlite3", ">= 2.0"
|
60
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,60 @@
|
|
1
1
|
# Audited ChangeLog
|
2
2
|
|
3
|
+
### 5.8.0 (2024-11-08)
|
4
|
+
- Allow calling audited multiple times - @mohammednasser-32
|
5
|
+
[734](https://github.com/collectiveidea/audited/pull/734)
|
6
|
+
- Relax gemspec to allow Rails 8.1 - @BranLiang
|
7
|
+
[738](https://github.com/collectiveidea/audited/pull/738)
|
8
|
+
|
9
|
+
### 5.7.0 (2024-08-13)
|
10
|
+
|
11
|
+
- Support for Rails 7.2 and Ruby 3.3, and testing cleanups - @mattbrictson
|
12
|
+
[#723](https://github.com/collectiveidea/audited/pull/723)
|
13
|
+
- Allow max_audits to be a proc or symbol - @gmhawash
|
14
|
+
[#718](https://github.com/collectiveidea/audited/pull/718)
|
15
|
+
- Support Rails 8 - @fernandomenolli
|
16
|
+
[#717](https://github.com/collectiveidea/audited/pull/717)
|
17
|
+
|
18
|
+
|
19
|
+
### 5.6.0 (2024-04-05)
|
20
|
+
|
21
|
+
- Removed support for Rails 5.0 and 5.1.
|
22
|
+
- Replace RequestStore with ActiveSupport::CurrentAttributes - @punkisdead
|
23
|
+
[#702](https://github.com/collectiveidea/audited/pull/702)
|
24
|
+
|
25
|
+
### 5.5.0 (2024-04-02)
|
26
|
+
|
27
|
+
- Bad release. Same code as 5.4.1. Use 5.6.0 for updated features.
|
28
|
+
|
29
|
+
### 5.4.3 (2024-01-11)
|
30
|
+
|
31
|
+
- Ignore readonly columns in audit - @sriddbs
|
32
|
+
[#692](https://github.com/collectiveidea/audited/pull/692)
|
33
|
+
- Robustify Rails version checks - @blaet
|
34
|
+
[#689](https://github.com/collectiveidea/audited/pull/689)
|
35
|
+
- Ignore callbacks if not specifed on the model
|
36
|
+
[#679](https://github.com/collectiveidea/audited/pull/679)
|
37
|
+
|
38
|
+
## 5.4.2 (2023-11-30)
|
39
|
+
|
40
|
+
- Revert replacing RequetStore with ActiveSupport::CurrentAttributes until it is fully tested.
|
41
|
+
|
42
|
+
## 5.4.1 (2023-11-30)
|
43
|
+
|
44
|
+
- Replace RequestStore with ActiveSupport::CurrentAttributes - @the-spectator
|
45
|
+
[#673](https://github.com/collectiveidea/audited/pull/673/)
|
46
|
+
- Don't require railtie when used outside of Rails - @nicduke38degrees
|
47
|
+
[#665](https://github.com/collectiveidea/audited/pull/665)
|
48
|
+
|
49
|
+
## 5.4.0 (2023-09-30)
|
50
|
+
|
51
|
+
- Add Rails 7.1 support - @yuki24
|
52
|
+
[#686](https://github.com/collectiveidea/audited/pull/686)
|
53
|
+
|
3
54
|
## 5.3.3 (2023-03-24)
|
4
55
|
|
5
56
|
- Use RequestStore instead of Thread.current for thread-safe requests - @tiagocassio
|
6
|
-
[#669](https://github.com/
|
57
|
+
[#669](https://github.com/c ollectiveidea/audited/pull/669)
|
7
58
|
- Clean up Touch audits - @mcyoung, @akostadinov
|
8
59
|
[#668](https://github.com/collectiveidea/audited/pull/668)
|
9
60
|
|
data/README.md
CHANGED
@@ -8,8 +8,9 @@ Audited
|
|
8
8
|
**Audited** (previously acts_as_audited) is an ORM extension that logs all changes to your models. Audited can also record who made those changes, save comments and associate models related to the changes.
|
9
9
|
|
10
10
|
|
11
|
-
Audited currently (5.
|
11
|
+
Audited currently (5.6) works with Rails 7.2, 7.1, 7.0, 6.1, 6.0, 5.2.
|
12
12
|
|
13
|
+
For Rails 5.0 & 5.1, use gem version 5.4.3
|
13
14
|
For Rails 4, use gem version 4.x
|
14
15
|
For Rails 3, use gem version 3.0 or see the [3.0-stable branch](https://github.com/collectiveidea/audited/tree/3.0-stable).
|
15
16
|
|
@@ -25,6 +26,7 @@ Audited supports and is [tested against](https://github.com/collectiveidea/audit
|
|
25
26
|
* 3.0
|
26
27
|
* 3.1
|
27
28
|
* 3.2
|
29
|
+
* 3.3
|
28
30
|
|
29
31
|
Audited may work just fine with a Ruby version not listed above, but we can't guarantee that it will. If you'd like to maintain a Ruby that isn't listed, please let us know with a [pull request](https://github.com/collectiveidea/audited/pulls).
|
30
32
|
|
@@ -133,18 +135,24 @@ end
|
|
133
135
|
|
134
136
|
### Specifying callbacks
|
135
137
|
|
136
|
-
By default, a new audit is created for any Create, Update or Destroy action. You can, however, limit the actions audited.
|
138
|
+
By default, a new audit is created for any Create, Update, Touch (Rails 6+) or Destroy action. You can, however, limit the actions audited.
|
137
139
|
|
138
140
|
```ruby
|
139
141
|
class User < ActiveRecord::Base
|
140
142
|
# All fields and actions
|
141
143
|
# audited
|
142
144
|
|
143
|
-
# Single field, only audit Update and Destroy (not Create)
|
145
|
+
# Single field, only audit Update and Destroy (not Create or Touch)
|
144
146
|
# audited only: :name, on: [:update, :destroy]
|
145
147
|
end
|
146
148
|
```
|
147
149
|
|
150
|
+
You can ignore the default callbacks globally unless the callback action is specified in your model using the `:on` option. To configure default callback exclusion, put the following in an initializer file (`config/initializers/audited.rb`):
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
Audited.ignored_default_callbacks = [:create, :update] # ignore callbacks create and update
|
154
|
+
```
|
155
|
+
|
148
156
|
### Comments
|
149
157
|
|
150
158
|
You can attach comments to each audit using an `audit_comment` attribute on your model.
|
data/Rakefile
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
|
3
|
-
require "bundler/
|
3
|
+
require "bundler/gem_tasks"
|
4
4
|
require "rspec/core/rake_task"
|
5
5
|
require "rake/testtask"
|
6
6
|
require "appraisal"
|
7
7
|
|
8
|
-
Bundler::GemHelper.install_tasks(name: "audited")
|
9
|
-
|
10
8
|
RSpec::Core::RakeTask.new(:spec)
|
11
9
|
|
12
10
|
Rake::TestTask.new do |t|
|
data/audited.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "audited/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "audited"
|
6
|
+
gem.version = Audited::VERSION
|
7
|
+
|
8
|
+
gem.authors = ["Brandon Keepers", "Kenneth Kalmer", "Daniel Morrison", "Brian Ryckbost", "Steve Richert", "Ryan Glover"]
|
9
|
+
gem.email = "info@collectiveidea.com"
|
10
|
+
gem.description = "Log all changes to your models"
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.homepage = "https://github.com/collectiveidea/audited"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\).reject { |f| f =~ /^(\.gemspec|\.git|\.standard|\.yard|gemfiles|test|spec)/ }
|
16
|
+
|
17
|
+
gem.required_ruby_version = ">= 2.3.0"
|
18
|
+
|
19
|
+
gem.add_dependency "activerecord", ">= 5.2", "< 8.2"
|
20
|
+
gem.add_dependency "activesupport", ">= 5.2", "< 8.2"
|
21
|
+
|
22
|
+
gem.add_development_dependency "appraisal"
|
23
|
+
gem.add_development_dependency "rails", ">= 5.2", "< 8.2"
|
24
|
+
gem.add_development_dependency "rspec-rails"
|
25
|
+
gem.add_development_dependency "standard"
|
26
|
+
gem.add_development_dependency "single_cov"
|
27
|
+
|
28
|
+
# JRuby support for the test ENV
|
29
|
+
if defined?(JRUBY_VERSION)
|
30
|
+
gem.add_development_dependency "activerecord-jdbcsqlite3-adapter", "~> 1.3"
|
31
|
+
gem.add_development_dependency "activerecord-jdbcpostgresql-adapter", "~> 1.3"
|
32
|
+
gem.add_development_dependency "activerecord-jdbcmysql-adapter", "~> 1.3"
|
33
|
+
else
|
34
|
+
gem.add_development_dependency "sqlite3", ">= 1.3.6"
|
35
|
+
gem.add_development_dependency "mysql2", ">= 0.3.20"
|
36
|
+
gem.add_development_dependency "pg", ">= 0.18", "< 2.0"
|
37
|
+
end
|
38
|
+
end
|
data/lib/audited/audit.rb
CHANGED
@@ -49,7 +49,11 @@ module Audited
|
|
49
49
|
cattr_accessor :audited_class_names
|
50
50
|
self.audited_class_names = Set.new
|
51
51
|
|
52
|
-
|
52
|
+
if Rails.gem_version >= Gem::Version.new("7.1")
|
53
|
+
serialize :audited_changes, coder: YAMLIfTextColumnType
|
54
|
+
else
|
55
|
+
serialize :audited_changes, YAMLIfTextColumnType
|
56
|
+
end
|
53
57
|
|
54
58
|
scope :ascending, -> { reorder(version: :asc) }
|
55
59
|
scope :descending, -> { reorder(version: :desc) }
|
data/lib/audited/auditor.rb
CHANGED
@@ -59,9 +59,16 @@ module Audited
|
|
59
59
|
# end
|
60
60
|
#
|
61
61
|
def audited(options = {})
|
62
|
-
|
63
|
-
|
62
|
+
audited? ? update_audited_options(options) : set_audit(options)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
64
66
|
|
67
|
+
def audited?
|
68
|
+
included_modules.include?(Audited::Auditor::AuditedInstanceMethods)
|
69
|
+
end
|
70
|
+
|
71
|
+
def set_audit(options)
|
65
72
|
extend Audited::Auditor::AuditedClassMethods
|
66
73
|
include Audited::Auditor::AuditedInstanceMethods
|
67
74
|
|
@@ -69,10 +76,7 @@ module Audited
|
|
69
76
|
class_attribute :audited_options, instance_writer: false
|
70
77
|
attr_accessor :audit_version, :audit_comment
|
71
78
|
|
72
|
-
|
73
|
-
normalize_audited_options
|
74
|
-
|
75
|
-
self.audit_associated_with = audited_options[:associated_with]
|
79
|
+
set_audited_options(options)
|
76
80
|
|
77
81
|
if audited_options[:comment_required]
|
78
82
|
validate :presence_of_audit_comment
|
@@ -100,6 +104,18 @@ module Audited
|
|
100
104
|
def has_associated_audits
|
101
105
|
has_many :associated_audits, as: :associated, class_name: Audited.audit_class.name
|
102
106
|
end
|
107
|
+
|
108
|
+
def update_audited_options(new_options)
|
109
|
+
previous_audit_options = self.audited_options
|
110
|
+
set_audited_options(new_options)
|
111
|
+
self.reset_audited_columns
|
112
|
+
end
|
113
|
+
|
114
|
+
def set_audited_options(options)
|
115
|
+
self.audited_options = options
|
116
|
+
normalize_audited_options
|
117
|
+
self.audit_associated_with = audited_options[:associated_with]
|
118
|
+
end
|
103
119
|
end
|
104
120
|
|
105
121
|
module AuditedInstanceMethods
|
@@ -231,7 +247,7 @@ module Audited
|
|
231
247
|
|
232
248
|
private
|
233
249
|
|
234
|
-
def audited_changes(for_touch: false)
|
250
|
+
def audited_changes(for_touch: false, exclude_readonly_attrs: false)
|
235
251
|
all_changes = if for_touch
|
236
252
|
previous_changes
|
237
253
|
elsif respond_to?(:changes_to_save)
|
@@ -240,6 +256,8 @@ module Audited
|
|
240
256
|
changes
|
241
257
|
end
|
242
258
|
|
259
|
+
all_changes = all_changes.except(*self.class.readonly_attributes.to_a) if exclude_readonly_attrs
|
260
|
+
|
243
261
|
filtered_changes = \
|
244
262
|
if audited_options[:only].present?
|
245
263
|
all_changes.slice(*self.class.audited_columns)
|
@@ -247,6 +265,8 @@ module Audited
|
|
247
265
|
all_changes.except(*self.class.non_audited_columns)
|
248
266
|
end
|
249
267
|
|
268
|
+
filtered_changes = normalize_enum_changes(filtered_changes)
|
269
|
+
|
250
270
|
if for_touch && (last_audit = audits.last&.audited_changes)
|
251
271
|
filtered_changes.reject! do |k, v|
|
252
272
|
last_audit[k].to_json == v.to_json ||
|
@@ -256,7 +276,6 @@ module Audited
|
|
256
276
|
|
257
277
|
filtered_changes = redact_values(filtered_changes)
|
258
278
|
filtered_changes = filter_encrypted_attrs(filtered_changes)
|
259
|
-
filtered_changes = normalize_enum_changes(filtered_changes)
|
260
279
|
filtered_changes.to_hash
|
261
280
|
end
|
262
281
|
|
@@ -333,14 +352,14 @@ module Audited
|
|
333
352
|
end
|
334
353
|
|
335
354
|
def audit_update
|
336
|
-
unless (changes = audited_changes).empty? && (audit_comment.blank? || audited_options[:update_with_comment_only] == false)
|
355
|
+
unless (changes = audited_changes(exclude_readonly_attrs: true)).empty? && (audit_comment.blank? || audited_options[:update_with_comment_only] == false)
|
337
356
|
write_audit(action: "update", audited_changes: changes,
|
338
357
|
comment: audit_comment)
|
339
358
|
end
|
340
359
|
end
|
341
360
|
|
342
361
|
def audit_touch
|
343
|
-
unless (changes = audited_changes(for_touch: true)).empty?
|
362
|
+
unless (changes = audited_changes(for_touch: true, exclude_readonly_attrs: true)).empty?
|
344
363
|
write_audit(action: "update", audited_changes: changes,
|
345
364
|
comment: audit_comment)
|
346
365
|
end
|
@@ -381,13 +400,25 @@ module Audited
|
|
381
400
|
end
|
382
401
|
|
383
402
|
def combine_audits_if_needed
|
384
|
-
max_audits =
|
403
|
+
max_audits = evaluate_max_audits
|
404
|
+
|
385
405
|
if max_audits && (extra_count = audits.count - max_audits) > 0
|
386
406
|
audits_to_combine = audits.limit(extra_count + 1)
|
387
407
|
combine_audits(audits_to_combine)
|
388
408
|
end
|
389
409
|
end
|
390
410
|
|
411
|
+
def evaluate_max_audits
|
412
|
+
max_audits = case (option = audited_options[:max_audits])
|
413
|
+
when Proc then option.call
|
414
|
+
when Symbol then send(option)
|
415
|
+
else
|
416
|
+
option
|
417
|
+
end
|
418
|
+
|
419
|
+
Integer(max_audits).abs if max_audits
|
420
|
+
end
|
421
|
+
|
391
422
|
def require_comment
|
392
423
|
if auditing_enabled && audit_comment.blank?
|
393
424
|
errors.add(:audit_comment, :blank)
|
@@ -496,11 +527,10 @@ module Audited
|
|
496
527
|
|
497
528
|
def normalize_audited_options
|
498
529
|
audited_options[:on] = Array.wrap(audited_options[:on])
|
499
|
-
audited_options[:on] = [:create, :update, :touch, :destroy] if audited_options[:on].empty?
|
530
|
+
audited_options[:on] = ([:create, :update, :touch, :destroy] - Audited.ignored_default_callbacks) if audited_options[:on].empty?
|
500
531
|
audited_options[:only] = Array.wrap(audited_options[:only]).map(&:to_s)
|
501
532
|
audited_options[:except] = Array.wrap(audited_options[:except]).map(&:to_s)
|
502
|
-
|
503
|
-
audited_options[:max_audits] = Integer(max_audits).abs if max_audits
|
533
|
+
audited_options[:max_audits] ||= Audited.max_audits
|
504
534
|
end
|
505
535
|
|
506
536
|
def calculate_non_audited_columns
|
@@ -516,6 +546,11 @@ module Audited
|
|
516
546
|
def class_auditing_enabled
|
517
547
|
Audited.store.fetch("#{table_name}_auditing_enabled", true)
|
518
548
|
end
|
549
|
+
|
550
|
+
def reset_audited_columns
|
551
|
+
@audited_columns = nil
|
552
|
+
@non_audited_columns = nil
|
553
|
+
end
|
519
554
|
end
|
520
555
|
end
|
521
556
|
end
|
data/lib/audited/version.rb
CHANGED
data/lib/audited.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_record"
|
4
|
-
require "request_store"
|
5
4
|
|
6
5
|
module Audited
|
6
|
+
# Wrapper around ActiveSupport::CurrentAttributes
|
7
|
+
class RequestStore < ActiveSupport::CurrentAttributes
|
8
|
+
attribute :audited_store
|
9
|
+
end
|
10
|
+
|
7
11
|
class << self
|
8
12
|
attr_accessor \
|
9
13
|
:auditing_enabled,
|
10
14
|
:current_user_method,
|
11
15
|
:ignored_attributes,
|
16
|
+
:ignored_default_callbacks,
|
12
17
|
:max_audits,
|
13
18
|
:store_synthesized_enums
|
14
19
|
attr_writer :audit_class
|
@@ -22,10 +27,11 @@ module Audited
|
|
22
27
|
|
23
28
|
# remove audit_model in next major version it was only shortly present in 5.1.0
|
24
29
|
alias_method :audit_model, :audit_class
|
25
|
-
deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed."
|
30
|
+
deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed.",
|
31
|
+
deprecator: ActiveSupport::Deprecation.new('6.0.0', 'Audited')
|
26
32
|
|
27
33
|
def store
|
28
|
-
RequestStore.
|
34
|
+
RequestStore.audited_store ||= {}
|
29
35
|
end
|
30
36
|
|
31
37
|
def config
|
@@ -34,6 +40,7 @@ module Audited
|
|
34
40
|
end
|
35
41
|
|
36
42
|
@ignored_attributes = %w[lock_version created_at updated_at created_on updated_on]
|
43
|
+
@ignored_default_callbacks = []
|
37
44
|
|
38
45
|
@current_user_method = :current_user
|
39
46
|
@auditing_enabled = true
|
@@ -48,4 +55,4 @@ ActiveSupport.on_load :active_record do
|
|
48
55
|
end
|
49
56
|
|
50
57
|
require "audited/sweeper"
|
51
|
-
require "audited/railtie"
|
58
|
+
require "audited/railtie" if Audited.const_defined?(:Rails)
|
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.
|
4
|
+
version: 5.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
@@ -10,10 +10,10 @@ authors:
|
|
10
10
|
- Brian Ryckbost
|
11
11
|
- Steve Richert
|
12
12
|
- Ryan Glover
|
13
|
-
autorequire:
|
13
|
+
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2024-11-08 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activerecord
|
@@ -21,34 +21,40 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '5.
|
24
|
+
version: '5.2'
|
25
25
|
- - "<"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '8.2'
|
28
28
|
type: :runtime
|
29
29
|
prerelease: false
|
30
30
|
version_requirements: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '5.
|
34
|
+
version: '5.2'
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '8.2'
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
39
|
+
name: activesupport
|
40
40
|
requirement: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- - "
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '5.2'
|
45
|
+
- - "<"
|
43
46
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
47
|
+
version: '8.2'
|
45
48
|
type: :runtime
|
46
49
|
prerelease: false
|
47
50
|
version_requirements: !ruby/object:Gem::Requirement
|
48
51
|
requirements:
|
49
|
-
- - "
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.2'
|
55
|
+
- - "<"
|
50
56
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
57
|
+
version: '8.2'
|
52
58
|
- !ruby/object:Gem::Dependency
|
53
59
|
name: appraisal
|
54
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,20 +75,20 @@ dependencies:
|
|
69
75
|
requirements:
|
70
76
|
- - ">="
|
71
77
|
- !ruby/object:Gem::Version
|
72
|
-
version: '5.
|
78
|
+
version: '5.2'
|
73
79
|
- - "<"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
81
|
+
version: '8.2'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - ">="
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '5.
|
88
|
+
version: '5.2'
|
83
89
|
- - "<"
|
84
90
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
91
|
+
version: '8.2'
|
86
92
|
- !ruby/object:Gem::Dependency
|
87
93
|
name: rspec-rails
|
88
94
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,23 +185,13 @@ executables: []
|
|
179
185
|
extensions: []
|
180
186
|
extra_rdoc_files: []
|
181
187
|
files:
|
182
|
-
- ".github/workflows/buildlight.yml"
|
183
|
-
- ".github/workflows/ci.yml"
|
184
|
-
- ".gitignore"
|
185
|
-
- ".standard.yml"
|
186
|
-
- ".yardopts"
|
187
188
|
- Appraisals
|
188
189
|
- CHANGELOG.md
|
189
190
|
- Gemfile
|
190
191
|
- LICENSE
|
191
192
|
- README.md
|
192
193
|
- Rakefile
|
193
|
-
-
|
194
|
-
- gemfiles/rails51.gemfile
|
195
|
-
- gemfiles/rails52.gemfile
|
196
|
-
- gemfiles/rails60.gemfile
|
197
|
-
- gemfiles/rails61.gemfile
|
198
|
-
- gemfiles/rails70.gemfile
|
194
|
+
- audited.gemspec
|
199
195
|
- lib/audited-rspec.rb
|
200
196
|
- lib/audited.rb
|
201
197
|
- lib/audited/audit.rb
|
@@ -218,40 +214,11 @@ files:
|
|
218
214
|
- lib/generators/audited/templates/rename_parent_to_association.rb
|
219
215
|
- lib/generators/audited/templates/revert_polymorphic_indexes_order.rb
|
220
216
|
- lib/generators/audited/upgrade_generator.rb
|
221
|
-
- spec/audited/audit_spec.rb
|
222
|
-
- spec/audited/auditor_spec.rb
|
223
|
-
- spec/audited/rspec_matchers_spec.rb
|
224
|
-
- spec/audited/sweeper_spec.rb
|
225
|
-
- spec/audited_spec.rb
|
226
|
-
- spec/audited_spec_helpers.rb
|
227
|
-
- spec/rails_app/app/assets/config/manifest.js
|
228
|
-
- spec/rails_app/config/application.rb
|
229
|
-
- spec/rails_app/config/database.yml
|
230
|
-
- spec/rails_app/config/environment.rb
|
231
|
-
- spec/rails_app/config/environments/test.rb
|
232
|
-
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
233
|
-
- spec/rails_app/config/initializers/inflections.rb
|
234
|
-
- spec/rails_app/config/initializers/secret_token.rb
|
235
|
-
- spec/rails_app/config/routes.rb
|
236
|
-
- spec/spec_helper.rb
|
237
|
-
- spec/support/active_record/models.rb
|
238
|
-
- spec/support/active_record/postgres/1_change_audited_changes_type_to_json.rb
|
239
|
-
- spec/support/active_record/postgres/2_change_audited_changes_type_to_jsonb.rb
|
240
|
-
- spec/support/active_record/schema.rb
|
241
|
-
- test/db/version_1.rb
|
242
|
-
- test/db/version_2.rb
|
243
|
-
- test/db/version_3.rb
|
244
|
-
- test/db/version_4.rb
|
245
|
-
- test/db/version_5.rb
|
246
|
-
- test/db/version_6.rb
|
247
|
-
- test/install_generator_test.rb
|
248
|
-
- test/test_helper.rb
|
249
|
-
- test/upgrade_generator_test.rb
|
250
217
|
homepage: https://github.com/collectiveidea/audited
|
251
218
|
licenses:
|
252
219
|
- MIT
|
253
220
|
metadata: {}
|
254
|
-
post_install_message:
|
221
|
+
post_install_message:
|
255
222
|
rdoc_options: []
|
256
223
|
require_paths:
|
257
224
|
- lib
|
@@ -266,8 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
233
|
- !ruby/object:Gem::Version
|
267
234
|
version: '0'
|
268
235
|
requirements: []
|
269
|
-
rubygems_version: 3.
|
270
|
-
signing_key:
|
236
|
+
rubygems_version: 3.5.22
|
237
|
+
signing_key:
|
271
238
|
specification_version: 4
|
272
239
|
summary: Log all changes to your models
|
273
240
|
test_files: []
|