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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e18ef251e91f3a66070afa58f5d9e5f12ac81777ca5389b3939a9fd349602e92
4
- data.tar.gz: c0fbd5a136b6e43ae6e39229de6690811d24adf4f1f2f555a49752cac3bd230b
3
+ metadata.gz: 86131fd51439ffb0e1e16fd0b3bdd770c0cdf6de5bc8df5f234377d9ef0aeddb
4
+ data.tar.gz: 4729941ef95dc9e6e542eb705ac12ff4876999c61f210a50d8ef460a02d71078
5
5
  SHA512:
6
- metadata.gz: 9bbb38bc63b2cbafd43b7090ab307acde19e9ca21d22710ddc7b42a5a10fc08f0151c1b43b557a1978699005ac66ce7932eec7f8d5f3de6b3c14d7a4d77c73af
7
- data.tar.gz: 707e5ddda189015b0475e663d7fb4faa3576a1a373dbe3f78436fce96e97cb7ed0a852fc328cec177716f95e035a45dd291f70888ba783572e4b854a84721a45
6
+ metadata.gz: 27d6c2bd685eaca06093e7b8352aa942b83163a09be96fade16cc39ac46502697ca264a54f7a99a4390afe6cc07fbca0d345cb4ad35d7a11d98fa8da9aa262dd
7
+ data.tar.gz: 615ffae5d0fe3a44ffde034ddd60a2074cdff6679b1a8d59b23adfa2fed557023ffd786516997627aaf3de7916c39666d85abd24b38b1562976678472bbc85a9
@@ -0,0 +1,15 @@
1
+ name: Buildlight
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows:
6
+ - CI
7
+ branches:
8
+ - main
9
+
10
+ jobs:
11
+ webhook:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Webhook
15
+ uses: collectiveidea/buildlight@main
@@ -4,7 +4,7 @@ on:
4
4
  pull_request:
5
5
  push:
6
6
  branches:
7
- - master
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
- # PostgresSQL is segfaulting on 2.3
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.audit_model.as_user(User.find(1)) do
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.audit_model.as_user("console-user-#{ENV['SSH_USER']}") do
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: http://rdoc.info/github/collectiveidea/audited
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
@@ -34,7 +34,7 @@ module Audited
34
34
  end
35
35
 
36
36
  def text_column?
37
- Audited.audit_model.columns_hash["audited_changes"].type.to_s == "text"
37
+ Audited.audit_class.columns_hash["audited_changes"].type.to_s == "text"
38
38
  end
39
39
  end
40
40
  end
@@ -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.audit_model.audited_class_names << to_s
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.audit_model.name
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.audit_model.reconstruct_attributes(audits_to(version))
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.audit_model.reconstruct_attributes(audits) unless audits.empty?
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.audit_model.unscoped.where(auditable: self)
183
- .or(Audited.audit_model.unscoped.where(associated: self))
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.audit_model.assign_revision_attributes(revision, attributes)
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.audit_model.as_user(user, &block)
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.audit_model.name
224
+ reflection.options[:class_name] == Audited.audit_class.name
225
225
  end
226
226
  end
227
227
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audited
4
- VERSION = "5.1.0"
4
+ VERSION = "5.2.0"
5
5
  end
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
- @audit_class ||= "Audited::Audit"
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
- def audit_model
20
- audit_class.constantize
21
- end
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)
@@ -62,7 +62,7 @@ describe Audited::Audit do
62
62
  end
63
63
 
64
64
  describe "#audited_changes" do
65
- let(:audit) { Audited.audit_model.new }
65
+ let(:audit) { Audited.audit_class.new }
66
66
 
67
67
  it "can unserialize yaml from text columns" do
68
68
  audit.audited_changes = {foo: "bar"}
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.1.0
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: 2022-12-23 00:00:00.000000000 Z
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"