audited 5.1.0 → 5.2.0
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 +4 -4
- data/.github/workflows/buildlight.yml +15 -0
- data/.github/workflows/ci.yml +2 -2
- data/CHANGELOG.md +12 -0
- data/README.md +4 -4
- data/lib/audited/audit.rb +1 -1
- data/lib/audited/auditor.rb +9 -9
- data/lib/audited/rspec_matchers.rb +1 -1
- data/lib/audited/version.rb +1 -1
- data/lib/audited.rb +7 -4
- data/spec/audited/audit_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86131fd51439ffb0e1e16fd0b3bdd770c0cdf6de5bc8df5f234377d9ef0aeddb
|
4
|
+
data.tar.gz: 4729941ef95dc9e6e542eb705ac12ff4876999c61f210a50d8ef460a02d71078
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27d6c2bd685eaca06093e7b8352aa942b83163a09be96fade16cc39ac46502697ca264a54f7a99a4390afe6cc07fbca0d345cb4ad35d7a11d98fa8da9aa262dd
|
7
|
+
data.tar.gz: 615ffae5d0fe3a44ffde034ddd60a2074cdff6679b1a8d59b23adfa2fed557023ffd786516997627aaf3de7916c39666d85abd24b38b1562976678472bbc85a9
|
data/.github/workflows/ci.yml
CHANGED
@@ -4,7 +4,7 @@ on:
|
|
4
4
|
pull_request:
|
5
5
|
push:
|
6
6
|
branches:
|
7
|
-
-
|
7
|
+
- main
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
build:
|
@@ -27,7 +27,7 @@ jobs:
|
|
27
27
|
- ruby: 2.3
|
28
28
|
db: MYSQL
|
29
29
|
|
30
|
-
#
|
30
|
+
# PostgreSQL is segfaulting on 2.3
|
31
31
|
# Doesn't seem worth solving.
|
32
32
|
- ruby: 2.3
|
33
33
|
db: POSTGRES
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Audited ChangeLog
|
2
2
|
|
3
|
+
## 5.2.0 (2023-01-23)
|
4
|
+
|
5
|
+
Improved
|
6
|
+
|
7
|
+
- config.audit_class can take a string or constant - @rocket-turtle
|
8
|
+
Fixes overzealous change in 5.1.0 where it only took a string.
|
9
|
+
[#648](https://github.com/collectiveidea/audited/pull/648)
|
10
|
+
- README link fix - @jeremiahlukus
|
11
|
+
[#646](https://github.com/collectiveidea/audited/pull/646)
|
12
|
+
- Typo fix in GitHub Actions - @jdufresne
|
13
|
+
[#644](https://github.com/collectiveidea/audited/pull/644)
|
14
|
+
|
3
15
|
## 5.1.0 (2022-12-23)
|
4
16
|
|
5
17
|
Changed
|
data/README.md
CHANGED
@@ -219,7 +219,7 @@ Audited.current_user_method = :authenticated_user
|
|
219
219
|
Outside of a request, Audited can still record the user with the `as_user` method:
|
220
220
|
|
221
221
|
```ruby
|
222
|
-
Audited.
|
222
|
+
Audited.audit_class.as_user(User.find(1)) do
|
223
223
|
post.update!(title: "Hello, world!")
|
224
224
|
end
|
225
225
|
post.audits.last.user # => #<User id: 1>
|
@@ -246,7 +246,7 @@ end
|
|
246
246
|
`as_user` also accepts a string, which can be useful for auditing updates made in a CLI environment:
|
247
247
|
|
248
248
|
```rb
|
249
|
-
Audited.
|
249
|
+
Audited.audit_class.as_user("console-user-#{ENV['SSH_USER']}") do
|
250
250
|
post.update_attributes!(title: "Hello, world!")
|
251
251
|
end
|
252
252
|
post.audits.last.user # => 'console-user-username'
|
@@ -314,7 +314,7 @@ If you want to audit only under specific conditions, you can provide conditional
|
|
314
314
|
```ruby
|
315
315
|
class User < ActiveRecord::Base
|
316
316
|
audited if: :active?
|
317
|
-
|
317
|
+
|
318
318
|
def active?
|
319
319
|
last_login > 6.months.ago
|
320
320
|
end
|
@@ -428,7 +428,7 @@ Audited.store_synthesized_enums = true
|
|
428
428
|
|
429
429
|
## Support
|
430
430
|
|
431
|
-
You can find documentation at:
|
431
|
+
You can find documentation at: https://www.rubydoc.info/gems/audited
|
432
432
|
|
433
433
|
Or join the [mailing list](http://groups.google.com/group/audited) to get help or offer suggestions.
|
434
434
|
|
data/lib/audited/audit.rb
CHANGED
data/lib/audited/auditor.rb
CHANGED
@@ -79,8 +79,8 @@ module Audited
|
|
79
79
|
before_destroy :require_comment if audited_options[:on].include?(:destroy)
|
80
80
|
end
|
81
81
|
|
82
|
-
has_many :audits, -> { order(version: :asc) }, as: :auditable, class_name: Audited.audit_class, inverse_of: :auditable
|
83
|
-
Audited.
|
82
|
+
has_many :audits, -> { order(version: :asc) }, as: :auditable, class_name: Audited.audit_class.name, inverse_of: :auditable
|
83
|
+
Audited.audit_class.audited_class_names << to_s
|
84
84
|
|
85
85
|
after_create :audit_create if audited_options[:on].include?(:create)
|
86
86
|
before_update :audit_update if audited_options[:on].include?(:update)
|
@@ -97,7 +97,7 @@ module Audited
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def has_associated_audits
|
100
|
-
has_many :associated_audits, as: :associated, class_name: Audited.
|
100
|
+
has_many :associated_audits, as: :associated, class_name: Audited.audit_class.name
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -159,14 +159,14 @@ module Audited
|
|
159
159
|
# Returns nil for versions greater than revisions count
|
160
160
|
def revision(version)
|
161
161
|
if version == :previous || audits.last.version >= version
|
162
|
-
revision_with Audited.
|
162
|
+
revision_with Audited.audit_class.reconstruct_attributes(audits_to(version))
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
# Find the oldest revision recorded prior to the date/time provided.
|
167
167
|
def revision_at(date_or_time)
|
168
168
|
audits = self.audits.up_until(date_or_time)
|
169
|
-
revision_with Audited.
|
169
|
+
revision_with Audited.audit_class.reconstruct_attributes(audits) unless audits.empty?
|
170
170
|
end
|
171
171
|
|
172
172
|
# List of attributes that are audited.
|
@@ -179,8 +179,8 @@ module Audited
|
|
179
179
|
|
180
180
|
# Returns a list combined of record audits and associated audits.
|
181
181
|
def own_and_associated_audits
|
182
|
-
Audited.
|
183
|
-
.or(Audited.
|
182
|
+
Audited.audit_class.unscoped.where(auditable: self)
|
183
|
+
.or(Audited.audit_class.unscoped.where(associated: self))
|
184
184
|
.order(created_at: :desc)
|
185
185
|
end
|
186
186
|
|
@@ -212,7 +212,7 @@ module Audited
|
|
212
212
|
revision.send :instance_variable_set, "@destroyed", false
|
213
213
|
revision.send :instance_variable_set, "@_destroyed", false
|
214
214
|
revision.send :instance_variable_set, "@marked_for_destruction", false
|
215
|
-
Audited.
|
215
|
+
Audited.audit_class.assign_revision_attributes(revision, attributes)
|
216
216
|
|
217
217
|
# Remove any association proxies so that they will be recreated
|
218
218
|
# and reference the correct object for this revision. The only way
|
@@ -455,7 +455,7 @@ module Audited
|
|
455
455
|
# convenience wrapper around
|
456
456
|
# @see Audit#as_user.
|
457
457
|
def audit_as(user, &block)
|
458
|
-
Audited.
|
458
|
+
Audited.audit_class.as_user(user, &block)
|
459
459
|
end
|
460
460
|
|
461
461
|
def auditing_enabled
|
@@ -221,7 +221,7 @@ module Audited
|
|
221
221
|
def association_exists?
|
222
222
|
!reflection.nil? &&
|
223
223
|
reflection.macro == :has_many &&
|
224
|
-
reflection.options[:class_name] == Audited.
|
224
|
+
reflection.options[:class_name] == Audited.audit_class.name
|
225
225
|
end
|
226
226
|
end
|
227
227
|
end
|
data/lib/audited/version.rb
CHANGED
data/lib/audited.rb
CHANGED
@@ -13,12 +13,15 @@ module Audited
|
|
13
13
|
attr_writer :audit_class
|
14
14
|
|
15
15
|
def audit_class
|
16
|
-
|
16
|
+
# The audit_class is set as String in the initializer. It can not be constantized during initialization and must
|
17
|
+
# be constantized at runtime. See https://github.com/collectiveidea/audited/issues/608
|
18
|
+
@audit_class = @audit_class.safe_constantize if @audit_class.is_a?(String)
|
19
|
+
@audit_class ||= Audited::Audit
|
17
20
|
end
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
# remove audit_model in next major version it was only shortly present in 5.1.0
|
23
|
+
alias_method :audit_model, :audit_class
|
24
|
+
deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed."
|
22
25
|
|
23
26
|
def store
|
24
27
|
current_store_value = Thread.current.thread_variable_get(:audited_store)
|
data/spec/audited/audit_spec.rb
CHANGED
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.2.0
|
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:
|
16
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activerecord
|
@@ -165,6 +165,7 @@ executables: []
|
|
165
165
|
extensions: []
|
166
166
|
extra_rdoc_files: []
|
167
167
|
files:
|
168
|
+
- ".github/workflows/buildlight.yml"
|
168
169
|
- ".github/workflows/ci.yml"
|
169
170
|
- ".gitignore"
|
170
171
|
- ".standard.yml"
|