audited 5.0.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 +4 -4
- data/Appraisals +40 -17
- data/CHANGELOG.md +143 -0
- data/README.md +49 -15
- data/Rakefile +1 -3
- data/audited.gemspec +38 -0
- data/lib/audited/audit.rb +8 -4
- data/lib/audited/auditor.rb +124 -38
- data/lib/audited/version.rb +1 -1
- data/lib/audited.rb +19 -10
- data/lib/generators/audited/migration.rb +10 -2
- metadata +39 -56
- data/.gitignore +0 -17
- data/.standard.yml +0 -5
- data/.travis.yml +0 -67
- data/.yardopts +0 -3
- data/gemfiles/rails50.gemfile +0 -10
- data/gemfiles/rails51.gemfile +0 -10
- data/gemfiles/rails52.gemfile +0 -10
- data/gemfiles/rails60.gemfile +0 -10
- data/gemfiles/rails61.gemfile +0 -10
- data/spec/audited/audit_spec.rb +0 -357
- data/spec/audited/auditor_spec.rb +0 -1097
- data/spec/audited/rspec_matchers_spec.rb +0 -69
- data/spec/audited/sweeper_spec.rb +0 -133
- data/spec/audited_spec.rb +0 -18
- 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 -13
- data/spec/rails_app/config/database.yml +0 -25
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/test.rb +0 -47
- 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 -151
- 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,37 +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
|
-
end
|
10
|
-
|
11
|
-
appraise "rails51" do
|
12
|
-
gem "rails", "~> 5.1.4"
|
13
|
-
gem "mysql2", ">= 0.3.18", "< 0.6.0"
|
14
|
-
gem "pg", ">= 0.18", "< 2.0"
|
15
|
-
gem "sqlite3", "~> 1.3.6"
|
16
|
-
end
|
17
|
-
|
18
4
|
appraise "rails52" do
|
19
|
-
gem "rails", "
|
5
|
+
gem "rails", "~> 5.2.8"
|
20
6
|
gem "mysql2", ">= 0.4.4", "< 0.6.0"
|
21
7
|
gem "pg", ">= 0.18", "< 2.0"
|
22
8
|
gem "sqlite3", "~> 1.3.6"
|
9
|
+
gem "psych", "~> 3.1"
|
10
|
+
gem "loofah", "2.20.0"
|
23
11
|
end
|
24
12
|
|
25
13
|
appraise "rails60" do
|
26
|
-
gem "rails", "
|
14
|
+
gem "rails", "~> 6.0.6"
|
27
15
|
gem "mysql2", ">= 0.4.4"
|
28
16
|
gem "pg", ">= 0.18", "< 2.0"
|
29
17
|
gem "sqlite3", "~> 1.4"
|
30
18
|
end
|
31
19
|
|
32
20
|
appraise "rails61" do
|
33
|
-
gem "rails", "
|
21
|
+
gem "rails", "~> 6.1.7"
|
34
22
|
gem "mysql2", ">= 0.4.4"
|
35
23
|
gem "pg", ">= 1.1", "< 2.0"
|
36
24
|
gem "sqlite3", "~> 1.4"
|
37
25
|
end
|
26
|
+
|
27
|
+
appraise "rails70" do
|
28
|
+
gem "rails", "~> 7.0.8"
|
29
|
+
gem "mysql2", ">= 0.4.4"
|
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"
|
45
|
+
gem "sqlite3", ">= 1.4"
|
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,148 @@
|
|
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
|
+
|
54
|
+
## 5.3.3 (2023-03-24)
|
55
|
+
|
56
|
+
- Use RequestStore instead of Thread.current for thread-safe requests - @tiagocassio
|
57
|
+
[#669](https://github.com/c ollectiveidea/audited/pull/669)
|
58
|
+
- Clean up Touch audits - @mcyoung, @akostadinov
|
59
|
+
[#668](https://github.com/collectiveidea/audited/pull/668)
|
60
|
+
|
61
|
+
## 5.3.2 (2023-02-22)
|
62
|
+
|
63
|
+
- Touch audit bug fixes - @mcyoung
|
64
|
+
[#662](https://github.com/collectiveidea/audited/pull/662)
|
65
|
+
|
66
|
+
## 5.3.1 (2023-02-21)
|
67
|
+
|
68
|
+
- Ensure touch support doesn't cause double audits - @mcyoung
|
69
|
+
[#660](https://github.com/collectiveidea/audited/pull/660)
|
70
|
+
- Testing Improvements - @vlad-psh
|
71
|
+
[#628](https://github.com/collectiveidea/audited/pull/628)
|
72
|
+
- Testing Improvements - @mcyoung
|
73
|
+
[#658](https://github.com/collectiveidea/audited/pull/658)
|
74
|
+
|
75
|
+
## 5.3.0 (2023-02-14)
|
76
|
+
|
77
|
+
- Audit touch calls - @mcyoung
|
78
|
+
[#657](https://github.com/collectiveidea/audited/pull/657)
|
79
|
+
- Allow using with Padrino and other non-Rails projects - @nicduke38degrees
|
80
|
+
[#655](https://github.com/collectiveidea/audited/pull/655)
|
81
|
+
- Testing updates - @jdufresne
|
82
|
+
[#652](https://github.com/collectiveidea/audited/pull/652)
|
83
|
+
[#653](https://github.com/collectiveidea/audited/pull/653)
|
84
|
+
|
85
|
+
## 5.2.0 (2023-01-23)
|
86
|
+
|
87
|
+
Improved
|
88
|
+
|
89
|
+
- config.audit_class can take a string or constant - @rocket-turtle
|
90
|
+
Fixes overzealous change in 5.1.0 where it only took a string.
|
91
|
+
[#648](https://github.com/collectiveidea/audited/pull/648)
|
92
|
+
- README link fix - @jeremiahlukus
|
93
|
+
[#646](https://github.com/collectiveidea/audited/pull/646)
|
94
|
+
- Typo fix in GitHub Actions - @jdufresne
|
95
|
+
[#644](https://github.com/collectiveidea/audited/pull/644)
|
96
|
+
|
97
|
+
## 5.1.0 (2022-12-23)
|
98
|
+
|
99
|
+
Changed
|
100
|
+
|
101
|
+
- config.audit_class takes a string - @simmerz
|
102
|
+
[#609](https://github.com/collectiveidea/audited/pull/609)
|
103
|
+
- Filter encrypted attributes automatically - @vlad-psh
|
104
|
+
[#630](https://github.com/collectiveidea/audited/pull/630)
|
105
|
+
|
106
|
+
Improved
|
107
|
+
|
108
|
+
- README improvements - @jess, @mstroming
|
109
|
+
[#605](https://github.com/collectiveidea/audited/pull/605)
|
110
|
+
[#640](https://github.com/collectiveidea/audited/issues/640)
|
111
|
+
- Ignore deadlocks in concurrent audit combinations - @Crammaman
|
112
|
+
[#621](https://github.com/collectiveidea/audited/pull/621)
|
113
|
+
- Fix timestamped_migrations deprecation warning - @shouichi
|
114
|
+
[#624](https://github.com/collectiveidea/audited/pull/624)
|
115
|
+
- Ensure audits are re-enabled after blocks - @dcorlett
|
116
|
+
[#632](https://github.com/collectiveidea/audited/pull/632)
|
117
|
+
- Replace raw string where clause with query methods - @macowie
|
118
|
+
[#642](https://github.com/collectiveidea/audited/pull/642)
|
119
|
+
- Test against more Ruby/Rails Versions - @enomotodev, @danielmorrison
|
120
|
+
[#610](https://github.com/collectiveidea/audited/pull/610)
|
121
|
+
[#643](https://github.com/collectiveidea/audited/pull/643)
|
122
|
+
|
123
|
+
## 5.0.2 (2021-09-16)
|
124
|
+
|
125
|
+
Added
|
126
|
+
|
127
|
+
- Relax ActiveRecord version constraint to support Rails 7
|
128
|
+
[#597](https://github.com/collectiveidea/audited/pull/597)
|
129
|
+
|
130
|
+
Improved
|
131
|
+
|
132
|
+
- Improve loading - @mvastola
|
133
|
+
[#592](https://github.com/collectiveidea/audited/pull/592)
|
134
|
+
- Update README - @danirod, @clement1234
|
135
|
+
[#596](https://github.com/collectiveidea/audited/pull/596)
|
136
|
+
[#594](https://github.com/collectiveidea/audited/pull/594)
|
137
|
+
|
138
|
+
|
139
|
+
## 5.0.1 (2021-06-11)
|
140
|
+
|
141
|
+
Improved
|
142
|
+
|
143
|
+
- Don't load associated model when auditing is disabled - @nut4k1
|
144
|
+
[#584](https://github.com/collectiveidea/audited/pull/584)
|
145
|
+
|
3
146
|
## 5.0.0 (2021-06-10)
|
4
147
|
|
5
148
|
Improved
|
data/README.md
CHANGED
@@ -1,23 +1,32 @@
|
|
1
|
-
Audited
|
1
|
+
Audited
|
2
|
+
[](http://rubygems.org/gems/audited)
|
3
|
+

|
4
|
+
[](https://codeclimate.com/github/collectiveidea/audited)
|
2
5
|
[](https://github.com/testdouble/standard)
|
3
6
|
=======
|
4
7
|
|
5
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.
|
6
9
|
|
7
10
|
|
8
|
-
Audited currently (5.
|
11
|
+
Audited currently (5.6) works with Rails 7.2, 7.1, 7.0, 6.1, 6.0, 5.2.
|
9
12
|
|
13
|
+
For Rails 5.0 & 5.1, use gem version 5.4.3
|
10
14
|
For Rails 4, use gem version 4.x
|
11
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).
|
12
16
|
|
13
17
|
## Supported Rubies
|
14
18
|
|
15
|
-
Audited supports and is [tested against](
|
19
|
+
Audited supports and is [tested against](https://github.com/collectiveidea/audited/actions/workflows/ci.yml) the following Ruby versions:
|
16
20
|
|
17
|
-
* 2.3
|
18
|
-
* 2.4
|
19
|
-
* 2.5
|
20
|
-
* 2.6
|
21
|
+
* 2.3 (only tested on Sqlite due to testing issues with other DBs)
|
22
|
+
* 2.4
|
23
|
+
* 2.5
|
24
|
+
* 2.6
|
25
|
+
* 2.7
|
26
|
+
* 3.0
|
27
|
+
* 3.1
|
28
|
+
* 3.2
|
29
|
+
* 3.3
|
21
30
|
|
22
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).
|
23
32
|
|
@@ -30,7 +39,16 @@ Audited is currently ActiveRecord-only. In a previous life, Audited worked with
|
|
30
39
|
Add the gem to your Gemfile:
|
31
40
|
|
32
41
|
```ruby
|
33
|
-
gem "audited"
|
42
|
+
gem "audited"
|
43
|
+
```
|
44
|
+
|
45
|
+
And if you're using ```require: false``` you must add initializers like this:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
#./config/initializers/audited.rb
|
49
|
+
require "audited"
|
50
|
+
|
51
|
+
Audited::Railtie.initializers.each(&:run)
|
34
52
|
```
|
35
53
|
|
36
54
|
Then, from your Rails app directory, create the `audits` table:
|
@@ -117,18 +135,24 @@ end
|
|
117
135
|
|
118
136
|
### Specifying callbacks
|
119
137
|
|
120
|
-
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.
|
121
139
|
|
122
140
|
```ruby
|
123
141
|
class User < ActiveRecord::Base
|
124
142
|
# All fields and actions
|
125
143
|
# audited
|
126
144
|
|
127
|
-
# Single field, only audit Update and Destroy (not Create)
|
145
|
+
# Single field, only audit Update and Destroy (not Create or Touch)
|
128
146
|
# audited only: :name, on: [:update, :destroy]
|
129
147
|
end
|
130
148
|
```
|
131
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
|
+
|
132
156
|
### Comments
|
133
157
|
|
134
158
|
You can attach comments to each audit using an `audit_comment` attribute on your model.
|
@@ -222,7 +246,7 @@ class ApplicationController < ActionController::Base
|
|
222
246
|
if current_user
|
223
247
|
current_user
|
224
248
|
else
|
225
|
-
'
|
249
|
+
'Alexander Fleming'
|
226
250
|
end
|
227
251
|
end
|
228
252
|
end
|
@@ -271,6 +295,7 @@ class User < ActiveRecord::Base
|
|
271
295
|
end
|
272
296
|
|
273
297
|
class Company < ActiveRecord::Base
|
298
|
+
audited
|
274
299
|
has_many :users
|
275
300
|
has_associated_audits
|
276
301
|
end
|
@@ -299,8 +324,6 @@ If you want to audit only under specific conditions, you can provide conditional
|
|
299
324
|
class User < ActiveRecord::Base
|
300
325
|
audited if: :active?
|
301
326
|
|
302
|
-
private
|
303
|
-
|
304
327
|
def active?
|
305
328
|
last_login > 6.months.ago
|
306
329
|
end
|
@@ -371,6 +394,17 @@ User.auditing_enabled = false
|
|
371
394
|
end
|
372
395
|
```
|
373
396
|
|
397
|
+
### Encrypted attributes
|
398
|
+
|
399
|
+
If you're using ActiveRecord's encryption (available from Rails 7) to encrypt some attributes, Audited will automatically filter values of these attributes. No additional configuration is required. Changes to encrypted attributes will be logged as `[FILTERED]`.
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
class User < ActiveRecord::Base
|
403
|
+
audited
|
404
|
+
encrypts :password
|
405
|
+
end
|
406
|
+
```
|
407
|
+
|
374
408
|
### Custom `Audit` model
|
375
409
|
|
376
410
|
If you want to extend or modify the audit model, create a new class that
|
@@ -387,7 +421,7 @@ Then set it in an initializer:
|
|
387
421
|
# config/initializers/audited.rb
|
388
422
|
|
389
423
|
Audited.config do |config|
|
390
|
-
config.audit_class = CustomAudit
|
424
|
+
config.audit_class = "CustomAudit"
|
391
425
|
end
|
392
426
|
```
|
393
427
|
|
@@ -403,7 +437,7 @@ Audited.store_synthesized_enums = true
|
|
403
437
|
|
404
438
|
## Support
|
405
439
|
|
406
|
-
You can find documentation at:
|
440
|
+
You can find documentation at: https://www.rubydoc.info/gems/audited
|
407
441
|
|
408
442
|
Or join the [mailing list](http://groups.google.com/group/audited) to get help or offer suggestions.
|
409
443
|
|
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) }
|
@@ -78,14 +82,14 @@ module Audited
|
|
78
82
|
# Returns a hash of the changed attributes with the new values
|
79
83
|
def new_attributes
|
80
84
|
(audited_changes || {}).each_with_object({}.with_indifferent_access) do |(attr, values), attrs|
|
81
|
-
attrs[attr] = (action == "update" ? values.last : values
|
85
|
+
attrs[attr] = (action == "update") ? values.last : values
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
89
|
# Returns a hash of the changed attributes with the old values
|
86
90
|
def old_attributes
|
87
91
|
(audited_changes || {}).each_with_object({}.with_indifferent_access) do |(attr, values), attrs|
|
88
|
-
attrs[attr] = (action == "update" ? values.first : values
|
92
|
+
attrs[attr] = (action == "update") ? values.first : values
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
@@ -174,7 +178,7 @@ module Audited
|
|
174
178
|
if action == "create"
|
175
179
|
self.version = 1
|
176
180
|
else
|
177
|
-
collection =
|
181
|
+
collection = (ActiveRecord::VERSION::MAJOR >= 6) ? self.class.unscoped : self.class
|
178
182
|
max = collection.auditable_finder(auditable_id, auditable_type).maximum(:version) || 0
|
179
183
|
self.version = max + 1
|
180
184
|
end
|