audited 4.3.0 → 4.6.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.
Potentially problematic release.
This version of audited might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +19 -2
- data/Appraisals +8 -2
- data/CHANGELOG.md +260 -0
- data/README.md +32 -12
- data/gemfiles/rails40.gemfile +1 -1
- data/gemfiles/rails41.gemfile +1 -1
- data/gemfiles/rails42.gemfile +1 -1
- data/gemfiles/rails50.gemfile +1 -2
- data/gemfiles/rails51.gemfile +7 -0
- data/gemfiles/rails52.gemfile +8 -0
- data/lib/audited.rb +6 -4
- data/lib/audited/audit.rb +57 -8
- data/lib/audited/auditor.rb +54 -59
- data/lib/audited/rspec_matchers.rb +2 -2
- data/lib/audited/sweeper.rb +18 -29
- data/lib/audited/version.rb +1 -1
- data/lib/generators/audited/install_generator.rb +5 -0
- data/lib/generators/audited/migration_helper.rb +9 -0
- data/lib/generators/audited/templates/add_association_to_audits.rb +1 -1
- data/lib/generators/audited/templates/add_comment_to_audits.rb +1 -1
- data/lib/generators/audited/templates/add_remote_address_to_audits.rb +1 -1
- data/lib/generators/audited/templates/add_request_uuid_to_audits.rb +1 -1
- data/lib/generators/audited/templates/install.rb +5 -5
- data/lib/generators/audited/templates/rename_association_to_associated.rb +1 -1
- data/lib/generators/audited/templates/rename_changes_to_audited_changes.rb +1 -1
- data/lib/generators/audited/templates/rename_parent_to_association.rb +1 -1
- data/lib/generators/audited/templates/revert_polymorphic_indexes_order.rb +20 -0
- data/lib/generators/audited/upgrade_generator.rb +7 -0
- data/spec/audited/audit_spec.rb +71 -2
- data/spec/audited/auditor_spec.rb +69 -3
- data/spec/audited/sweeper_spec.rb +24 -6
- data/spec/audited_spec_helpers.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/active_record/models.rb +2 -1
- data/spec/support/active_record/postgres/1_change_audited_changes_type_to_json.rb +12 -0
- data/spec/support/active_record/postgres/2_change_audited_changes_type_to_jsonb.rb +12 -0
- data/spec/support/active_record/schema.rb +1 -0
- data/test/install_generator_test.rb +49 -3
- data/test/upgrade_generator_test.rb +16 -1
- metadata +14 -22
- data/CHANGELOG +0 -34
@@ -5,7 +5,7 @@ module Models
|
|
5
5
|
module ActiveRecord
|
6
6
|
class User < ::ActiveRecord::Base
|
7
7
|
audited allow_mass_assignment: true, except: :password
|
8
|
-
|
8
|
+
attribute :non_column_attr if Rails.version >= '5.1'
|
9
9
|
attr_protected :logins if respond_to?(:attr_protected)
|
10
10
|
|
11
11
|
def name=(val)
|
@@ -15,6 +15,7 @@ module Models
|
|
15
15
|
|
16
16
|
class UserOnlyPassword < ::ActiveRecord::Base
|
17
17
|
self.table_name = :users
|
18
|
+
attribute :non_column_attr if Rails.version >= '5.1'
|
18
19
|
audited allow_mass_assignment: true, only: :password
|
19
20
|
end
|
20
21
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
parent = Rails::VERSION::MAJOR == 4 ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
|
2
|
+
class ChangeAuditedChangesTypeToJson < parent
|
3
|
+
def self.up
|
4
|
+
remove_column :audits, :audited_changes
|
5
|
+
add_column :audits, :audited_changes, :json
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.down
|
9
|
+
remove_column :audits, :audited_changes
|
10
|
+
add_column :audits, :audited_changes, :text
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
parent = Rails::VERSION::MAJOR == 4 ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
|
2
|
+
class ChangeAuditedChangesTypeToJsonb < parent
|
3
|
+
def self.up
|
4
|
+
remove_column :audits, :audited_changes
|
5
|
+
add_column :audits, :audited_changes, :jsonb
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.down
|
9
|
+
remove_column :audits, :audited_changes
|
10
|
+
add_column :audits, :audited_changes, :text
|
11
|
+
end
|
12
|
+
end
|
@@ -7,11 +7,57 @@ class InstallGeneratorTest < Rails::Generators::TestCase
|
|
7
7
|
setup :prepare_destination
|
8
8
|
tests Audited::Generators::InstallGenerator
|
9
9
|
|
10
|
-
test "
|
11
|
-
run_generator
|
10
|
+
test "generate migration with 'text' type for audited_changes column" do
|
11
|
+
run_generator
|
12
12
|
|
13
13
|
assert_migration "db/migrate/install_audited.rb" do |content|
|
14
|
-
|
14
|
+
assert_includes(content, 'class InstallAudited')
|
15
|
+
assert_includes(content, 't.column :audited_changes, :text')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
test "generate migration with 'jsonb' type for audited_changes column" do
|
20
|
+
run_generator %w(--audited-changes-column-type jsonb)
|
21
|
+
|
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')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
test "generate migration with 'json' type for audited_changes column" do
|
29
|
+
run_generator %w(--audited-changes-column-type json)
|
30
|
+
|
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')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
test "generate migration with 'string' type for user_id column" do
|
38
|
+
run_generator %w(--audited-user-id-column-type string)
|
39
|
+
|
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')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
test "generate migration with 'uuid' type for user_id column" do
|
47
|
+
run_generator %w(--audited-user-id-column-type uuid)
|
48
|
+
|
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')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
test "generate migration with correct AR migration parent" do
|
56
|
+
run_generator
|
57
|
+
|
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")
|
15
61
|
end
|
16
62
|
end
|
17
63
|
end
|
@@ -6,7 +6,11 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
|
|
6
6
|
destination File.expand_path('../../tmp', __FILE__)
|
7
7
|
setup :prepare_destination
|
8
8
|
tests Audited::Generators::UpgradeGenerator
|
9
|
-
|
9
|
+
if Rails::VERSION::MAJOR == 4
|
10
|
+
self.use_transactional_fixtures = false
|
11
|
+
else
|
12
|
+
self.use_transactional_tests = false
|
13
|
+
end
|
10
14
|
|
11
15
|
test "should add 'comment' to audits table" do
|
12
16
|
load_schema 1
|
@@ -74,4 +78,15 @@ class UpgradeGeneratorTest < Rails::Generators::TestCase
|
|
74
78
|
assert_match(/add_index :audits, :request_uuid/, content)
|
75
79
|
end
|
76
80
|
end
|
81
|
+
|
82
|
+
test "generate migration with correct AR migration parent" do
|
83
|
+
load_schema 1
|
84
|
+
|
85
|
+
run_generator %w(upgrade)
|
86
|
+
|
87
|
+
assert_migration "db/migrate/add_comment_to_audits.rb" do |content|
|
88
|
+
parent = Rails::VERSION::MAJOR == 4 ? 'ActiveRecord::Migration' : "ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]"
|
89
|
+
assert_includes(content, "class AddCommentToAudits < #{parent}\n")
|
90
|
+
end
|
91
|
+
end
|
77
92
|
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.
|
4
|
+
version: 4.6.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: 2018-01-09 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: '4.0'
|
25
25
|
- - "<"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '5.
|
27
|
+
version: '5.2'
|
28
28
|
type: :runtime
|
29
29
|
prerelease: false
|
30
30
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -34,21 +34,7 @@ dependencies:
|
|
34
34
|
version: '4.0'
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '5.
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: rails-observers
|
40
|
-
requirement: !ruby/object:Gem::Requirement
|
41
|
-
requirements:
|
42
|
-
- - "~>"
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 0.1.2
|
45
|
-
type: :runtime
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: !ruby/object:Gem::Requirement
|
48
|
-
requirements:
|
49
|
-
- - "~>"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: 0.1.2
|
37
|
+
version: '5.2'
|
52
38
|
- !ruby/object:Gem::Dependency
|
53
39
|
name: appraisal
|
54
40
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +58,7 @@ dependencies:
|
|
72
58
|
version: '4.0'
|
73
59
|
- - "<"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '5.
|
61
|
+
version: '5.2'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -82,7 +68,7 @@ dependencies:
|
|
82
68
|
version: '4.0'
|
83
69
|
- - "<"
|
84
70
|
- !ruby/object:Gem::Version
|
85
|
-
version: '5.
|
71
|
+
version: '5.2'
|
86
72
|
- !ruby/object:Gem::Dependency
|
87
73
|
name: rspec-rails
|
88
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,7 +135,7 @@ files:
|
|
149
135
|
- ".travis.yml"
|
150
136
|
- ".yardopts"
|
151
137
|
- Appraisals
|
152
|
-
- CHANGELOG
|
138
|
+
- CHANGELOG.md
|
153
139
|
- Gemfile
|
154
140
|
- LICENSE
|
155
141
|
- README.md
|
@@ -158,6 +144,8 @@ files:
|
|
158
144
|
- gemfiles/rails41.gemfile
|
159
145
|
- gemfiles/rails42.gemfile
|
160
146
|
- gemfiles/rails50.gemfile
|
147
|
+
- gemfiles/rails51.gemfile
|
148
|
+
- gemfiles/rails52.gemfile
|
161
149
|
- lib/audited-rspec.rb
|
162
150
|
- lib/audited.rb
|
163
151
|
- lib/audited/audit.rb
|
@@ -167,6 +155,7 @@ files:
|
|
167
155
|
- lib/audited/version.rb
|
168
156
|
- lib/generators/audited/install_generator.rb
|
169
157
|
- lib/generators/audited/migration.rb
|
158
|
+
- lib/generators/audited/migration_helper.rb
|
170
159
|
- lib/generators/audited/templates/add_association_to_audits.rb
|
171
160
|
- lib/generators/audited/templates/add_comment_to_audits.rb
|
172
161
|
- lib/generators/audited/templates/add_remote_address_to_audits.rb
|
@@ -175,6 +164,7 @@ files:
|
|
175
164
|
- lib/generators/audited/templates/rename_association_to_associated.rb
|
176
165
|
- lib/generators/audited/templates/rename_changes_to_audited_changes.rb
|
177
166
|
- lib/generators/audited/templates/rename_parent_to_association.rb
|
167
|
+
- lib/generators/audited/templates/revert_polymorphic_indexes_order.rb
|
178
168
|
- lib/generators/audited/upgrade_generator.rb
|
179
169
|
- spec/audited/audit_spec.rb
|
180
170
|
- spec/audited/auditor_spec.rb
|
@@ -192,6 +182,8 @@ files:
|
|
192
182
|
- spec/rails_app/config/routes.rb
|
193
183
|
- spec/spec_helper.rb
|
194
184
|
- spec/support/active_record/models.rb
|
185
|
+
- spec/support/active_record/postgres/1_change_audited_changes_type_to_json.rb
|
186
|
+
- spec/support/active_record/postgres/2_change_audited_changes_type_to_jsonb.rb
|
195
187
|
- spec/support/active_record/schema.rb
|
196
188
|
- test/db/version_1.rb
|
197
189
|
- test/db/version_2.rb
|
@@ -222,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
214
|
version: '0'
|
223
215
|
requirements: []
|
224
216
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.6.
|
217
|
+
rubygems_version: 2.6.13
|
226
218
|
signing_key:
|
227
219
|
specification_version: 4
|
228
220
|
summary: Log all changes to your models
|
data/CHANGELOG
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
Audited ChangeLog
|
2
|
-
-------------------------------------------------------------------------------
|
3
|
-
* 2012-04-10 - Add Audit scopes for creates, updates and destroys [chriswfx]
|
4
|
-
* 2011-10-25 - Made ignored_attributes configurable [senny]
|
5
|
-
* 2011-09-09 - Rails 3.x support
|
6
|
-
Support for associated audits
|
7
|
-
Support for remote IP address storage
|
8
|
-
Plenty of bug fixes and refactoring
|
9
|
-
[kennethkalmer, ineu, PatrickMa, jrozner, dwarburton, bsiggelkow, dgm]
|
10
|
-
* 2009-01-27 - Store old and new values for updates, and store all attributes on destroy.
|
11
|
-
Refactored revisioning methods to work as expected
|
12
|
-
* 2008-10-10 - changed to make it work in development mode
|
13
|
-
* 2008-09-24 - Add ability to record parent record of the record being audited
|
14
|
-
[Kenneth Kalmer]
|
15
|
-
* 2008-04-19 - refactored to make compatible with dirty tracking in edge rails
|
16
|
-
and to stop storing both old and new values in a single audit
|
17
|
-
* 2008-04-18 - Fix NoMethodError when trying to access the :previous revision
|
18
|
-
on a model that doesn't have previous revisions [Alex Soto]
|
19
|
-
* 2008-03-21 - added #changed_attributes to get access to the changes before a
|
20
|
-
save [Chris Parker]
|
21
|
-
* 2007-12-16 - Added #revision_at for retrieving a revision from a specific
|
22
|
-
time [Jacob Atzen]
|
23
|
-
* 2007-12-16 - Fix error when getting revision from audit with no changes
|
24
|
-
[Geoffrey Wiseman]
|
25
|
-
* 2007-12-16 - Remove dependency on acts_as_list
|
26
|
-
* 2007-06-17 - Added support getting previous revisions
|
27
|
-
* 2006-11-17 - Replaced use of singleton User.current_user with cache sweeper
|
28
|
-
implementation for auditing the user that made the change
|
29
|
-
* 2006-11-17 - added migration generator
|
30
|
-
* 2006-08-14 - incorporated changes from Michael Schuerig to write_attribute
|
31
|
-
that saves the new value after every change and not just the
|
32
|
-
first, and performs proper type-casting before doing comparisons
|
33
|
-
* 2006-08-14 - The "changes" are now saved as a serialized hash
|
34
|
-
* 2006-07-21 - initial version
|