audited 4.8.0 → 4.9.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 +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +25 -0
- data/.travis.yml +27 -27
- data/Appraisals +21 -11
- data/CHANGELOG.md +34 -3
- data/README.md +52 -17
- data/gemfiles/rails42.gemfile +3 -0
- data/gemfiles/rails50.gemfile +3 -0
- data/gemfiles/rails51.gemfile +3 -0
- data/gemfiles/rails52.gemfile +3 -1
- data/gemfiles/rails60.gemfile +10 -0
- data/lib/audited/audit.rb +8 -10
- data/lib/audited/auditor.rb +60 -23
- data/lib/audited/version.rb +1 -1
- data/spec/audited/audit_spec.rb +69 -21
- data/spec/audited/auditor_spec.rb +127 -32
- data/spec/audited/sweeper_spec.rb +13 -5
- data/spec/rails_app/app/controllers/application_controller.rb +2 -0
- data/spec/rails_app/config/database.yml +1 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/active_record/models.rb +6 -0
- data/spec/support/active_record/schema.rb +3 -2
- metadata +53 -19
- data/gemfiles/rails40.gemfile +0 -9
- data/gemfiles/rails41.gemfile +0 -8
@@ -1,5 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
+
SingleCov.covered! uncovered: 2 # 2 conditional on_load conditions
|
4
|
+
|
3
5
|
class AuditsController < ActionController::Base
|
4
6
|
before_action :populate_user
|
5
7
|
|
@@ -11,7 +13,7 @@ class AuditsController < ActionController::Base
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def update
|
14
|
-
current_user.
|
16
|
+
current_user.update!(password: 'foo')
|
15
17
|
head :ok
|
16
18
|
end
|
17
19
|
|
@@ -27,14 +29,13 @@ describe AuditsController do
|
|
27
29
|
include RSpec::Rails::ControllerExampleGroup
|
28
30
|
render_views
|
29
31
|
|
30
|
-
before
|
32
|
+
before do
|
31
33
|
Audited.current_user_method = :current_user
|
32
34
|
end
|
33
35
|
|
34
36
|
let(:user) { create_user }
|
35
37
|
|
36
38
|
describe "POST audit" do
|
37
|
-
|
38
39
|
it "should audit user" do
|
39
40
|
controller.send(:current_user=, user)
|
40
41
|
expect {
|
@@ -44,6 +45,15 @@ describe AuditsController do
|
|
44
45
|
expect(controller.company.audits.last.user).to eq(user)
|
45
46
|
end
|
46
47
|
|
48
|
+
it "does not audit when method is not found" do
|
49
|
+
controller.send(:current_user=, user)
|
50
|
+
Audited.current_user_method = :nope
|
51
|
+
expect {
|
52
|
+
post :create
|
53
|
+
}.to change( Audited::Audit, :count )
|
54
|
+
expect(controller.company.audits.last.user).to eq(nil)
|
55
|
+
end
|
56
|
+
|
47
57
|
it "should support custom users for sweepers" do
|
48
58
|
controller.send(:custom_user=, user)
|
49
59
|
Audited.current_user_method = :custom_user
|
@@ -84,7 +94,6 @@ describe AuditsController do
|
|
84
94
|
|
85
95
|
expect(controller.company.audits.last.user).to eq(user)
|
86
96
|
end
|
87
|
-
|
88
97
|
end
|
89
98
|
|
90
99
|
describe "PUT update" do
|
@@ -98,7 +107,6 @@ describe AuditsController do
|
|
98
107
|
end
|
99
108
|
end
|
100
109
|
|
101
|
-
|
102
110
|
describe Audited::Sweeper do
|
103
111
|
|
104
112
|
it "should be thread-safe" do
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,7 @@ module Models
|
|
7
7
|
audited except: :password
|
8
8
|
attribute :non_column_attr if Rails.version >= '5.1'
|
9
9
|
attr_protected :logins if respond_to?(:attr_protected)
|
10
|
+
enum status: { active: 0, reliable: 1, banned: 2 }
|
10
11
|
|
11
12
|
def name=(val)
|
12
13
|
write_attribute(:name, CGI.escapeHTML(val))
|
@@ -44,6 +45,11 @@ module Models
|
|
44
45
|
audited comment_required: true, on: :destroy
|
45
46
|
end
|
46
47
|
|
48
|
+
class NoUpdateWithCommentOnlyUser < ::ActiveRecord::Base
|
49
|
+
self.table_name = :users
|
50
|
+
audited update_with_comment_only: false
|
51
|
+
end
|
52
|
+
|
47
53
|
class AccessibleAfterDeclarationUser < ::ActiveRecord::Base
|
48
54
|
self.table_name = :users
|
49
55
|
audited
|
@@ -15,10 +15,10 @@ begin
|
|
15
15
|
db_config[:configure_connection] = false
|
16
16
|
end
|
17
17
|
adapter = ActiveRecord::Base.send("#{db_type}_connection", db_config)
|
18
|
-
adapter.recreate_database db_name
|
18
|
+
adapter.recreate_database db_name, db_config.slice('charset').symbolize_keys
|
19
19
|
adapter.disconnect!
|
20
20
|
end
|
21
|
-
rescue
|
21
|
+
rescue => e
|
22
22
|
Kernel.warn e
|
23
23
|
end
|
24
24
|
|
@@ -35,6 +35,7 @@ ActiveRecord::Schema.define do
|
|
35
35
|
t.column :username, :string
|
36
36
|
t.column :password, :string
|
37
37
|
t.column :activated, :boolean
|
38
|
+
t.column :status, :integer, default: 0
|
38
39
|
t.column :suspended_at, :datetime
|
39
40
|
t.column :logins, :integer, default: 0
|
40
41
|
t.column :created_at, :datetime
|
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.9.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: 2019-07-18 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.
|
24
|
+
version: '4.2'
|
25
25
|
- - "<"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '6.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.
|
34
|
+
version: '4.2'
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '6.1'
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: appraisal
|
40
40
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,20 +55,34 @@ dependencies:
|
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '4.
|
58
|
+
version: '4.2'
|
59
59
|
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '6.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.
|
68
|
+
version: '4.2'
|
69
69
|
- - "<"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
71
|
+
version: '6.1'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rubocop
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.54.0
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.54.0
|
72
86
|
- !ruby/object:Gem::Dependency
|
73
87
|
name: rspec-rails
|
74
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,6 +97,20 @@ dependencies:
|
|
83
97
|
- - "~>"
|
84
98
|
- !ruby/object:Gem::Version
|
85
99
|
version: '3.5'
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: single_cov
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
type: :development
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
86
114
|
- !ruby/object:Gem::Dependency
|
87
115
|
name: sqlite3
|
88
116
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,30 +129,36 @@ dependencies:
|
|
101
129
|
name: mysql2
|
102
130
|
requirement: !ruby/object:Gem::Requirement
|
103
131
|
requirements:
|
104
|
-
- - "
|
132
|
+
- - ">="
|
105
133
|
- !ruby/object:Gem::Version
|
106
134
|
version: 0.3.20
|
107
135
|
type: :development
|
108
136
|
prerelease: false
|
109
137
|
version_requirements: !ruby/object:Gem::Requirement
|
110
138
|
requirements:
|
111
|
-
- - "
|
139
|
+
- - ">="
|
112
140
|
- !ruby/object:Gem::Version
|
113
141
|
version: 0.3.20
|
114
142
|
- !ruby/object:Gem::Dependency
|
115
143
|
name: pg
|
116
144
|
requirement: !ruby/object:Gem::Requirement
|
117
145
|
requirements:
|
118
|
-
- - "
|
146
|
+
- - ">="
|
119
147
|
- !ruby/object:Gem::Version
|
120
148
|
version: '0.18'
|
149
|
+
- - "<"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '2.0'
|
121
152
|
type: :development
|
122
153
|
prerelease: false
|
123
154
|
version_requirements: !ruby/object:Gem::Requirement
|
124
155
|
requirements:
|
125
|
-
- - "
|
156
|
+
- - ">="
|
126
157
|
- !ruby/object:Gem::Version
|
127
158
|
version: '0.18'
|
159
|
+
- - "<"
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '2.0'
|
128
162
|
description: Log all changes to your models
|
129
163
|
email: info@collectiveidea.com
|
130
164
|
executables: []
|
@@ -132,6 +166,7 @@ extensions: []
|
|
132
166
|
extra_rdoc_files: []
|
133
167
|
files:
|
134
168
|
- ".gitignore"
|
169
|
+
- ".rubocop.yml"
|
135
170
|
- ".travis.yml"
|
136
171
|
- ".yardopts"
|
137
172
|
- Appraisals
|
@@ -140,12 +175,11 @@ files:
|
|
140
175
|
- LICENSE
|
141
176
|
- README.md
|
142
177
|
- Rakefile
|
143
|
-
- gemfiles/rails40.gemfile
|
144
|
-
- gemfiles/rails41.gemfile
|
145
178
|
- gemfiles/rails42.gemfile
|
146
179
|
- gemfiles/rails50.gemfile
|
147
180
|
- gemfiles/rails51.gemfile
|
148
181
|
- gemfiles/rails52.gemfile
|
182
|
+
- gemfiles/rails60.gemfile
|
149
183
|
- lib/audited-rspec.rb
|
150
184
|
- lib/audited.rb
|
151
185
|
- lib/audited/audit.rb
|
@@ -172,6 +206,7 @@ files:
|
|
172
206
|
- spec/audited/rspec_matchers_spec.rb
|
173
207
|
- spec/audited/sweeper_spec.rb
|
174
208
|
- spec/audited_spec_helpers.rb
|
209
|
+
- spec/rails_app/app/controllers/application_controller.rb
|
175
210
|
- spec/rails_app/config/application.rb
|
176
211
|
- spec/rails_app/config/database.yml
|
177
212
|
- spec/rails_app/config/environment.rb
|
@@ -208,15 +243,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
243
|
requirements:
|
209
244
|
- - ">="
|
210
245
|
- !ruby/object:Gem::Version
|
211
|
-
version:
|
246
|
+
version: 2.3.0
|
212
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
248
|
requirements:
|
214
249
|
- - ">="
|
215
250
|
- !ruby/object:Gem::Version
|
216
251
|
version: '0'
|
217
252
|
requirements: []
|
218
|
-
|
219
|
-
rubygems_version: 2.6.13
|
253
|
+
rubygems_version: 3.0.4
|
220
254
|
signing_key:
|
221
255
|
specification_version: 4
|
222
256
|
summary: Log all changes to your models
|
data/gemfiles/rails40.gemfile
DELETED