audited 5.6.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f68b2608cf53ed7087873504b4f29c97599bf31a79d284a3675c1725c91bfba
4
- data.tar.gz: 62a32603313de542d0e9aa261110d0be63ba50c56e3073bd828e8492681ec7cf
3
+ metadata.gz: e0bfd7a5ca6d490f0462b5605cca4406ee60edbc1684953a3262f1395662b1a4
4
+ data.tar.gz: 4bf6e8845875c22900eb94d9dc0cfd73ddb0f065e379b59648bbd1555f3a0db8
5
5
  SHA512:
6
- metadata.gz: de9505c3076a24b043ba3128f526709def0c4c9dbe2a6ac56dab7163b252efa20e94c84f9481fb7c3e5673eee822e18654949736693e42e4e00285149cc639f0
7
- data.tar.gz: 88d44336e6e2e61952a973d9b44957d68375cc18e009ac0fc410638b9748dcd4a331dcb15224f073e28077c84ee0f50c8d5e848f559925ebedca77696ca35f32
6
+ metadata.gz: ce188b4c71689ef96dce51e1affb292dc5f98c8fee625241e6d929ed361887bfa4643c975ac7ce031eddff2956dcfbc5bf4e630f58fa9f5a4bb46e6f06d05d9e
7
+ data.tar.gz: 305b28ac6501b9bc159fdab34fbd013202e797669072721ce7cb765ad7f7a779ae9893e3ad1eab634d6a7be785c658c4a7b7e8ee1baceb48683ad6a1e1f67b78
data/Appraisals CHANGED
@@ -1,26 +1,8 @@
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
- gem "loofah", "2.20.0"
11
- end
12
-
13
- appraise "rails51" do
14
- gem "rails", "~> 5.1.4"
15
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
16
- gem "pg", ">= 0.18", "< 2.0"
17
- gem "sqlite3", "~> 1.3.6"
18
- gem "psych", "~> 3.1"
19
- gem "loofah", "2.20.0"
20
- end
21
-
22
4
  appraise "rails52" do
23
- gem "rails", ">= 5.2.8.1", "< 5.3"
5
+ gem "rails", "~> 5.2.8"
24
6
  gem "mysql2", ">= 0.4.4", "< 0.6.0"
25
7
  gem "pg", ">= 0.18", "< 2.0"
26
8
  gem "sqlite3", "~> 1.3.6"
@@ -29,29 +11,50 @@ appraise "rails52" do
29
11
  end
30
12
 
31
13
  appraise "rails60" do
32
- gem "rails", ">= 6.0.0", "< 6.1"
14
+ gem "rails", "~> 6.0.6"
33
15
  gem "mysql2", ">= 0.4.4"
34
16
  gem "pg", ">= 0.18", "< 2.0"
35
17
  gem "sqlite3", "~> 1.4"
36
18
  end
37
19
 
38
20
  appraise "rails61" do
39
- gem "rails", ">= 6.1.0", "< 6.2"
21
+ gem "rails", "~> 6.1.7"
40
22
  gem "mysql2", ">= 0.4.4"
41
23
  gem "pg", ">= 1.1", "< 2.0"
42
24
  gem "sqlite3", "~> 1.4"
43
25
  end
44
26
 
45
27
  appraise "rails70" do
46
- gem "rails", ">= 7.0.0", "< 7.1"
28
+ gem "rails", "~> 7.0.8"
47
29
  gem "mysql2", ">= 0.4.4"
48
30
  gem "pg", ">= 1.1"
49
- gem "sqlite3", ">= 1.4"
31
+ gem "sqlite3", "~> 1.4"
50
32
  end
51
33
 
52
34
  appraise "rails71" do
53
- gem "rails", ">= 7.1.0.beta1", "< 7.2"
35
+ gem "rails", "~> 7.1.3"
54
36
  gem "mysql2", ">= 0.4.4"
55
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"
56
45
  gem "sqlite3", ">= 1.4"
57
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,5 +1,21 @@
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
+
3
19
  ### 5.6.0 (2024-04-05)
4
20
 
5
21
  - Removed support for Rails 5.0 and 5.1.
@@ -38,7 +54,7 @@
38
54
  ## 5.3.3 (2023-03-24)
39
55
 
40
56
  - Use RequestStore instead of Thread.current for thread-safe requests - @tiagocassio
41
- [#669](https://github.com/collectiveidea/audited/pull/669)
57
+ [#669](https://github.com/c ollectiveidea/audited/pull/669)
42
58
  - Clean up Touch audits - @mcyoung, @akostadinov
43
59
  [#668](https://github.com/collectiveidea/audited/pull/668)
44
60
 
data/README.md CHANGED
@@ -8,7 +8,7 @@ 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.6) works with Rails 7.1, 7.0, 6.1, 6.0, 5.2.
11
+ Audited currently (5.6) works with Rails 7.2, 7.1, 7.0, 6.1, 6.0, 5.2.
12
12
 
13
13
  For Rails 5.0 & 5.1, use gem version 5.4.3
14
14
  For Rails 4, use gem version 4.x
@@ -26,6 +26,7 @@ Audited supports and is [tested against](https://github.com/collectiveidea/audit
26
26
  * 3.0
27
27
  * 3.1
28
28
  * 3.2
29
+ * 3.3
29
30
 
30
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).
31
32
 
data/audited.gemspec CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.required_ruby_version = ">= 2.3.0"
18
18
 
19
- gem.add_dependency "activerecord", ">= 5.2", "< 7.2"
20
- gem.add_dependency "activesupport", ">= 5.2", "< 7.2"
19
+ gem.add_dependency "activerecord", ">= 5.2", "< 8.2"
20
+ gem.add_dependency "activesupport", ">= 5.2", "< 8.2"
21
21
 
22
22
  gem.add_development_dependency "appraisal"
23
- gem.add_development_dependency "rails", ">= 5.2", "< 7.2"
23
+ gem.add_development_dependency "rails", ">= 5.2", "< 8.2"
24
24
  gem.add_development_dependency "rspec-rails"
25
25
  gem.add_development_dependency "standard"
26
26
  gem.add_development_dependency "single_cov"
@@ -59,9 +59,16 @@ module Audited
59
59
  # end
60
60
  #
61
61
  def audited(options = {})
62
- # don't allow multiple calls
63
- return if included_modules.include?(Audited::Auditor::AuditedInstanceMethods)
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
- self.audited_options = options
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
@@ -384,13 +400,25 @@ module Audited
384
400
  end
385
401
 
386
402
  def combine_audits_if_needed
387
- max_audits = audited_options[:max_audits]
403
+ max_audits = evaluate_max_audits
404
+
388
405
  if max_audits && (extra_count = audits.count - max_audits) > 0
389
406
  audits_to_combine = audits.limit(extra_count + 1)
390
407
  combine_audits(audits_to_combine)
391
408
  end
392
409
  end
393
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
+
394
422
  def require_comment
395
423
  if auditing_enabled && audit_comment.blank?
396
424
  errors.add(:audit_comment, :blank)
@@ -502,8 +530,7 @@ module Audited
502
530
  audited_options[:on] = ([:create, :update, :touch, :destroy] - Audited.ignored_default_callbacks) if audited_options[:on].empty?
503
531
  audited_options[:only] = Array.wrap(audited_options[:only]).map(&:to_s)
504
532
  audited_options[:except] = Array.wrap(audited_options[:except]).map(&:to_s)
505
- max_audits = audited_options[:max_audits] || Audited.max_audits
506
- audited_options[:max_audits] = Integer(max_audits).abs if max_audits
533
+ audited_options[:max_audits] ||= Audited.max_audits
507
534
  end
508
535
 
509
536
  def calculate_non_audited_columns
@@ -519,6 +546,11 @@ module Audited
519
546
  def class_auditing_enabled
520
547
  Audited.store.fetch("#{table_name}_auditing_enabled", true)
521
548
  end
549
+
550
+ def reset_audited_columns
551
+ @audited_columns = nil
552
+ @non_audited_columns = nil
553
+ end
522
554
  end
523
555
  end
524
556
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audited
4
- VERSION = "5.6.0"
4
+ VERSION = "5.8.0"
5
5
  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.6.0
4
+ version: 5.8.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: 2024-04-05 00:00:00.000000000 Z
16
+ date: 2024-11-08 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: '5.2'
25
25
  - - "<"
26
26
  - !ruby/object:Gem::Version
27
- version: '7.2'
27
+ version: '8.2'
28
28
  type: :runtime
29
29
  prerelease: false
30
30
  version_requirements: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: '5.2'
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
- version: '7.2'
37
+ version: '8.2'
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: activesupport
40
40
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '5.2'
45
45
  - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '7.2'
47
+ version: '8.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '5.2'
55
55
  - - "<"
56
56
  - !ruby/object:Gem::Version
57
- version: '7.2'
57
+ version: '8.2'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: appraisal
60
60
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '5.2'
79
79
  - - "<"
80
80
  - !ruby/object:Gem::Version
81
- version: '7.2'
81
+ version: '8.2'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
@@ -88,7 +88,7 @@ dependencies:
88
88
  version: '5.2'
89
89
  - - "<"
90
90
  - !ruby/object:Gem::Version
91
- version: '7.2'
91
+ version: '8.2'
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: rspec-rails
94
94
  requirement: !ruby/object:Gem::Requirement
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.5.3
236
+ rubygems_version: 3.5.22
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: Log all changes to your models