audited 4.9.0 → 5.0.2

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.

Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +115 -0
  3. data/.standard.yml +5 -0
  4. data/Appraisals +22 -16
  5. data/CHANGELOG.md +68 -1
  6. data/Gemfile +1 -1
  7. data/README.md +49 -11
  8. data/Rakefile +6 -6
  9. data/gemfiles/rails60.gemfile +1 -1
  10. data/gemfiles/rails61.gemfile +10 -0
  11. data/gemfiles/rails70.gemfile +10 -0
  12. data/lib/audited/audit.rb +36 -28
  13. data/lib/audited/auditor.rb +69 -43
  14. data/lib/audited/railtie.rb +16 -0
  15. data/lib/audited/rspec_matchers.rb +5 -3
  16. data/lib/audited/sweeper.rb +3 -10
  17. data/lib/audited/version.rb +3 -1
  18. data/lib/audited-rspec.rb +3 -1
  19. data/lib/audited.rb +25 -8
  20. data/lib/generators/audited/install_generator.rb +9 -7
  21. data/lib/generators/audited/migration.rb +2 -0
  22. data/lib/generators/audited/migration_helper.rb +3 -1
  23. data/lib/generators/audited/templates/add_association_to_audits.rb +2 -0
  24. data/lib/generators/audited/templates/add_comment_to_audits.rb +2 -0
  25. data/lib/generators/audited/templates/add_remote_address_to_audits.rb +2 -0
  26. data/lib/generators/audited/templates/add_request_uuid_to_audits.rb +2 -0
  27. data/lib/generators/audited/templates/add_version_to_auditable_index.rb +2 -0
  28. data/lib/generators/audited/templates/install.rb +2 -0
  29. data/lib/generators/audited/templates/rename_association_to_associated.rb +2 -0
  30. data/lib/generators/audited/templates/rename_changes_to_audited_changes.rb +2 -0
  31. data/lib/generators/audited/templates/rename_parent_to_association.rb +2 -0
  32. data/lib/generators/audited/templates/revert_polymorphic_indexes_order.rb +2 -0
  33. data/lib/generators/audited/upgrade_generator.rb +16 -14
  34. data/spec/audited/audit_spec.rb +69 -47
  35. data/spec/audited/auditor_spec.rb +310 -246
  36. data/spec/audited/sweeper_spec.rb +19 -18
  37. data/spec/audited_spec.rb +18 -0
  38. data/spec/audited_spec_helpers.rb +7 -7
  39. data/spec/rails_app/app/assets/config/manifest.js +2 -0
  40. data/spec/rails_app/config/application.rb +3 -3
  41. data/spec/rails_app/config/database.yml +3 -2
  42. data/spec/rails_app/config/environment.rb +1 -1
  43. data/spec/rails_app/config/environments/test.rb +5 -5
  44. data/spec/rails_app/config/initializers/secret_token.rb +2 -2
  45. data/spec/spec_helper.rb +14 -14
  46. data/spec/support/active_record/models.rb +31 -12
  47. data/spec/support/active_record/postgres/1_change_audited_changes_type_to_json.rb +1 -2
  48. data/spec/support/active_record/postgres/2_change_audited_changes_type_to_jsonb.rb +1 -2
  49. data/spec/support/active_record/schema.rb +26 -19
  50. data/test/db/version_1.rb +2 -2
  51. data/test/db/version_2.rb +2 -2
  52. data/test/db/version_3.rb +2 -3
  53. data/test/db/version_4.rb +2 -3
  54. data/test/db/version_5.rb +0 -1
  55. data/test/db/version_6.rb +1 -1
  56. data/test/install_generator_test.rb +18 -19
  57. data/test/test_helper.rb +5 -5
  58. data/test/upgrade_generator_test.rb +13 -18
  59. metadata +31 -30
  60. data/.rubocop.yml +0 -25
  61. data/.travis.yml +0 -58
  62. data/gemfiles/rails42.gemfile +0 -11
  63. data/spec/rails_app/app/controllers/application_controller.rb +0 -2
  64. data/spec/rails_app/config/environments/development.rb +0 -21
  65. data/spec/rails_app/config/environments/production.rb +0 -35
data/test/db/version_1.rb CHANGED
@@ -11,7 +11,7 @@ ActiveRecord::Schema.define do
11
11
  t.column :created_at, :datetime
12
12
  end
13
13
 
14
- add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
15
- add_index :audits, [:user_id, :user_type], name: 'user_index'
14
+ add_index :audits, [:auditable_id, :auditable_type], name: "auditable_index"
15
+ add_index :audits, [:user_id, :user_type], name: "user_index"
16
16
  add_index :audits, :created_at
17
17
  end
data/test/db/version_2.rb CHANGED
@@ -12,7 +12,7 @@ ActiveRecord::Schema.define do
12
12
  t.column :created_at, :datetime
13
13
  end
14
14
 
15
- add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
16
- add_index :audits, [:user_id, :user_type], name: 'user_index'
15
+ add_index :audits, [:auditable_id, :auditable_type], name: "auditable_index"
16
+ add_index :audits, [:user_id, :user_type], name: "user_index"
17
17
  add_index :audits, :created_at
18
18
  end
data/test/db/version_3.rb CHANGED
@@ -12,8 +12,7 @@ ActiveRecord::Schema.define do
12
12
  t.column :created_at, :datetime
13
13
  end
14
14
 
15
- add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
16
- add_index :audits, [:user_id, :user_type], name: 'user_index'
15
+ add_index :audits, [:auditable_id, :auditable_type], name: "auditable_index"
16
+ add_index :audits, [:user_id, :user_type], name: "user_index"
17
17
  add_index :audits, :created_at
18
18
  end
19
-
data/test/db/version_4.rb CHANGED
@@ -13,8 +13,7 @@ ActiveRecord::Schema.define do
13
13
  t.column :remote_address, :string
14
14
  end
15
15
 
16
- add_index :audits, [:auditable_id, :auditable_type], name: 'auditable_index'
17
- add_index :audits, [:user_id, :user_type], name: 'user_index'
16
+ add_index :audits, [:auditable_id, :auditable_type], name: "auditable_index"
17
+ add_index :audits, [:user_id, :user_type], name: "user_index"
18
18
  add_index :audits, :created_at
19
19
  end
20
-
data/test/db/version_5.rb CHANGED
@@ -15,4 +15,3 @@ ActiveRecord::Schema.define do
15
15
  t.column :association_type, :string
16
16
  end
17
17
  end
18
-
data/test/db/version_6.rb CHANGED
@@ -15,5 +15,5 @@ ActiveRecord::Schema.define do
15
15
  t.column :associated_type, :string
16
16
  end
17
17
 
18
- add_index :audits, [:auditable_type, :auditable_id], name: 'auditable_index'
18
+ add_index :audits, [:auditable_type, :auditable_id], name: "auditable_index"
19
19
  end
@@ -1,9 +1,9 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
- require 'generators/audited/install_generator'
3
+ require "generators/audited/install_generator"
4
4
 
5
5
  class InstallGeneratorTest < Rails::Generators::TestCase
6
- destination File.expand_path('../../tmp', __FILE__)
6
+ destination File.expand_path("../../tmp", __FILE__)
7
7
  setup :prepare_destination
8
8
  tests Audited::Generators::InstallGenerator
9
9
 
@@ -11,44 +11,44 @@ class InstallGeneratorTest < Rails::Generators::TestCase
11
11
  run_generator
12
12
 
13
13
  assert_migration "db/migrate/install_audited.rb" do |content|
14
- assert_includes(content, 'class InstallAudited')
15
- assert_includes(content, 't.column :audited_changes, :text')
14
+ assert_includes(content, "class InstallAudited")
15
+ assert_includes(content, "t.column :audited_changes, :text")
16
16
  end
17
17
  end
18
18
 
19
19
  test "generate migration with 'jsonb' type for audited_changes column" do
20
- run_generator %w(--audited-changes-column-type jsonb)
20
+ run_generator %w[--audited-changes-column-type jsonb]
21
21
 
22
22
  assert_migration "db/migrate/install_audited.rb" do |content|
23
- assert_includes(content, 'class InstallAudited')
24
- assert_includes(content, 't.column :audited_changes, :jsonb')
23
+ assert_includes(content, "class InstallAudited")
24
+ assert_includes(content, "t.column :audited_changes, :jsonb")
25
25
  end
26
26
  end
27
27
 
28
28
  test "generate migration with 'json' type for audited_changes column" do
29
- run_generator %w(--audited-changes-column-type json)
29
+ run_generator %w[--audited-changes-column-type json]
30
30
 
31
31
  assert_migration "db/migrate/install_audited.rb" do |content|
32
- assert_includes(content, 'class InstallAudited')
33
- assert_includes(content, 't.column :audited_changes, :json')
32
+ assert_includes(content, "class InstallAudited")
33
+ assert_includes(content, "t.column :audited_changes, :json")
34
34
  end
35
35
  end
36
36
 
37
37
  test "generate migration with 'string' type for user_id column" do
38
- run_generator %w(--audited-user-id-column-type string)
38
+ run_generator %w[--audited-user-id-column-type string]
39
39
 
40
40
  assert_migration "db/migrate/install_audited.rb" do |content|
41
- assert_includes(content, 'class InstallAudited')
42
- assert_includes(content, 't.column :user_id, :string')
41
+ assert_includes(content, "class InstallAudited")
42
+ assert_includes(content, "t.column :user_id, :string")
43
43
  end
44
44
  end
45
45
 
46
46
  test "generate migration with 'uuid' type for user_id column" do
47
- run_generator %w(--audited-user-id-column-type uuid)
47
+ run_generator %w[--audited-user-id-column-type uuid]
48
48
 
49
49
  assert_migration "db/migrate/install_audited.rb" do |content|
50
- assert_includes(content, 'class InstallAudited')
51
- assert_includes(content, 't.column :user_id, :uuid')
50
+ assert_includes(content, "class InstallAudited")
51
+ assert_includes(content, "t.column :user_id, :uuid")
52
52
  end
53
53
  end
54
54
 
@@ -56,8 +56,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
56
56
  run_generator
57
57
 
58
58
  assert_migration "db/migrate/install_audited.rb" do |content|
59
- parent = Rails::VERSION::MAJOR == 4 ? 'ActiveRecord::Migration' : "ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]"
60
- assert_includes(content, "class InstallAudited < #{parent}\n")
59
+ assert_includes(content, "class InstallAudited < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]\n")
61
60
  end
62
61
  end
63
62
  end
data/test/test_helper.rb CHANGED
@@ -1,18 +1,18 @@
1
- ENV['RAILS_ENV'] = 'test'
1
+ ENV["RAILS_ENV"] = "test"
2
2
 
3
3
  $LOAD_PATH.unshift File.dirname(__FILE__)
4
4
 
5
- require File.expand_path('../../spec/rails_app/config/environment', __FILE__)
6
- require 'rails/test_help'
5
+ require File.expand_path("../../spec/rails_app/config/environment", __FILE__)
6
+ require "rails/test_help"
7
7
 
8
- require 'audited'
8
+ require "audited"
9
9
 
10
10
  class ActiveSupport::TestCase
11
11
  setup do
12
12
  ActiveRecord::Migration.verbose = false
13
13
  end
14
14
 
15
- def load_schema( version )
15
+ def load_schema(version)
16
16
  load File.dirname(__FILE__) + "/db/version_#{version}.rb"
17
17
  end
18
18
  end
@@ -1,21 +1,17 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
- require 'generators/audited/upgrade_generator'
3
+ require "generators/audited/upgrade_generator"
4
4
 
5
5
  class UpgradeGeneratorTest < Rails::Generators::TestCase
6
- destination File.expand_path('../../tmp', __FILE__)
6
+ destination File.expand_path("../../tmp", __FILE__)
7
7
  setup :prepare_destination
8
8
  tests Audited::Generators::UpgradeGenerator
9
- if Rails::VERSION::MAJOR == 4
10
- self.use_transactional_fixtures = false
11
- else
12
- self.use_transactional_tests = false
13
- end
9
+ self.use_transactional_tests = false
14
10
 
15
11
  test "should add 'comment' to audits table" do
16
12
  load_schema 1
17
13
 
18
- run_generator %w(upgrade)
14
+ run_generator %w[upgrade]
19
15
 
20
16
  assert_migration "db/migrate/add_comment_to_audits.rb" do |content|
21
17
  assert_match(/add_column :audits, :comment, :string/, content)
@@ -27,7 +23,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
27
23
  test "should rename 'changes' to 'audited_changes'" do
28
24
  load_schema 2
29
25
 
30
- run_generator %w(upgrade)
26
+ run_generator %w[upgrade]
31
27
 
32
28
  assert_no_migration "db/migrate/add_comment_to_audits.rb"
33
29
 
@@ -39,7 +35,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
39
35
  test "should add a 'remote_address' to audits table" do
40
36
  load_schema 3
41
37
 
42
- run_generator %w(upgrade)
38
+ run_generator %w[upgrade]
43
39
 
44
40
  assert_migration "db/migrate/add_remote_address_to_audits.rb" do |content|
45
41
  assert_match(/add_column :audits, :remote_address, :string/, content)
@@ -49,7 +45,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
49
45
  test "should add 'association_id' and 'association_type' to audits table" do
50
46
  load_schema 4
51
47
 
52
- run_generator %w(upgrade)
48
+ run_generator %w[upgrade]
53
49
 
54
50
  assert_migration "db/migrate/add_association_to_audits.rb" do |content|
55
51
  assert_match(/add_column :audits, :association_id, :integer/, content)
@@ -60,7 +56,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
60
56
  test "should rename 'association_id' to 'associated_id' and 'association_type' to 'associated_type'" do
61
57
  load_schema 5
62
58
 
63
- run_generator %w(upgrade)
59
+ run_generator %w[upgrade]
64
60
 
65
61
  assert_migration "db/migrate/rename_association_to_associated.rb" do |content|
66
62
  assert_match(/rename_column :audits, :association_id, :associated_id/, content)
@@ -71,7 +67,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
71
67
  test "should add 'request_uuid' to audits table" do
72
68
  load_schema 6
73
69
 
74
- run_generator %w(upgrade)
70
+ run_generator %w[upgrade]
75
71
 
76
72
  assert_migration "db/migrate/add_request_uuid_to_audits.rb" do |content|
77
73
  assert_match(/add_column :audits, :request_uuid, :string/, content)
@@ -82,7 +78,7 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
82
78
  test "should add 'version' to auditable_index" do
83
79
  load_schema 6
84
80
 
85
- run_generator %w(upgrade)
81
+ run_generator %w[upgrade]
86
82
 
87
83
  assert_migration "db/migrate/add_version_to_auditable_index.rb" do |content|
88
84
  assert_match(/add_index :audits, \[:auditable_type, :auditable_id, :version\]/, content)
@@ -92,11 +88,10 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
92
88
  test "generate migration with correct AR migration parent" do
93
89
  load_schema 1
94
90
 
95
- run_generator %w(upgrade)
91
+ run_generator %w[upgrade]
96
92
 
97
93
  assert_migration "db/migrate/add_comment_to_audits.rb" do |content|
98
- parent = Rails::VERSION::MAJOR == 4 ? 'ActiveRecord::Migration' : "ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]"
99
- assert_includes(content, "class AddCommentToAudits < #{parent}\n")
94
+ assert_includes(content, "class AddCommentToAudits < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]\n")
100
95
  end
101
96
  end
102
97
  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: 4.9.0
4
+ version: 5.0.2
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: 2019-07-18 00:00:00.000000000 Z
16
+ date: 2021-09-16 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord
@@ -21,20 +21,20 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: '4.2'
24
+ version: '5.0'
25
25
  - - "<"
26
26
  - !ruby/object:Gem::Version
27
- version: '6.1'
27
+ version: '7.1'
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: '4.2'
34
+ version: '5.0'
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
- version: '6.1'
37
+ version: '7.1'
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: appraisal
40
40
  requirement: !ruby/object:Gem::Requirement
@@ -55,48 +55,48 @@ dependencies:
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
- version: '4.2'
58
+ version: '5.0'
59
59
  - - "<"
60
60
  - !ruby/object:Gem::Version
61
- version: '6.1'
61
+ version: '7.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '4.2'
68
+ version: '5.0'
69
69
  - - "<"
70
70
  - !ruby/object:Gem::Version
71
- version: '6.1'
71
+ version: '7.1'
72
72
  - !ruby/object:Gem::Dependency
73
- name: rubocop
73
+ name: rspec-rails
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - "~>"
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
- version: 0.54.0
78
+ version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - "~>"
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.54.0
85
+ version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
- name: rspec-rails
87
+ name: standard
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - "~>"
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: '3.5'
92
+ version: '0'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: '3.5'
99
+ version: '0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: single_cov
102
102
  requirement: !ruby/object:Gem::Requirement
@@ -165,9 +165,9 @@ executables: []
165
165
  extensions: []
166
166
  extra_rdoc_files: []
167
167
  files:
168
+ - ".github/workflows/ci.yml"
168
169
  - ".gitignore"
169
- - ".rubocop.yml"
170
- - ".travis.yml"
170
+ - ".standard.yml"
171
171
  - ".yardopts"
172
172
  - Appraisals
173
173
  - CHANGELOG.md
@@ -175,15 +175,17 @@ files:
175
175
  - LICENSE
176
176
  - README.md
177
177
  - Rakefile
178
- - gemfiles/rails42.gemfile
179
178
  - gemfiles/rails50.gemfile
180
179
  - gemfiles/rails51.gemfile
181
180
  - gemfiles/rails52.gemfile
182
181
  - gemfiles/rails60.gemfile
182
+ - gemfiles/rails61.gemfile
183
+ - gemfiles/rails70.gemfile
183
184
  - lib/audited-rspec.rb
184
185
  - lib/audited.rb
185
186
  - lib/audited/audit.rb
186
187
  - lib/audited/auditor.rb
188
+ - lib/audited/railtie.rb
187
189
  - lib/audited/rspec_matchers.rb
188
190
  - lib/audited/sweeper.rb
189
191
  - lib/audited/version.rb
@@ -205,13 +207,12 @@ files:
205
207
  - spec/audited/auditor_spec.rb
206
208
  - spec/audited/rspec_matchers_spec.rb
207
209
  - spec/audited/sweeper_spec.rb
210
+ - spec/audited_spec.rb
208
211
  - spec/audited_spec_helpers.rb
209
- - spec/rails_app/app/controllers/application_controller.rb
212
+ - spec/rails_app/app/assets/config/manifest.js
210
213
  - spec/rails_app/config/application.rb
211
214
  - spec/rails_app/config/database.yml
212
215
  - spec/rails_app/config/environment.rb
213
- - spec/rails_app/config/environments/development.rb
214
- - spec/rails_app/config/environments/production.rb
215
216
  - spec/rails_app/config/environments/test.rb
216
217
  - spec/rails_app/config/initializers/backtrace_silencers.rb
217
218
  - spec/rails_app/config/initializers/inflections.rb
@@ -235,7 +236,7 @@ homepage: https://github.com/collectiveidea/audited
235
236
  licenses:
236
237
  - MIT
237
238
  metadata: {}
238
- post_install_message:
239
+ post_install_message:
239
240
  rdoc_options: []
240
241
  require_paths:
241
242
  - lib
@@ -250,8 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
251
  - !ruby/object:Gem::Version
251
252
  version: '0'
252
253
  requirements: []
253
- rubygems_version: 3.0.4
254
- signing_key:
254
+ rubygems_version: 3.1.6
255
+ signing_key:
255
256
  specification_version: 4
256
257
  summary: Log all changes to your models
257
258
  test_files: []
data/.rubocop.yml DELETED
@@ -1,25 +0,0 @@
1
- AllCops:
2
- DisplayCopNames: true
3
- TargetRubyVersion: 2.3
4
- Exclude:
5
- - lib/generators/audited/templates/**/*
6
- - vendor/bundle/**/*
7
- - gemfiles/vendor/bundle/**/*
8
-
9
- Bundler/OrderedGems:
10
- Enabled: false
11
-
12
- Gemspec/OrderedDependencies:
13
- Enabled: false
14
-
15
- Layout:
16
- Enabled: false
17
-
18
- Metrics:
19
- Enabled: false
20
-
21
- Naming:
22
- Enabled: false
23
-
24
- Style:
25
- Enabled: false