audited 4.5.0 → 4.6.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 +4 -4
- data/.travis.yml +12 -5
- data/Appraisals +6 -1
- data/CHANGELOG.md +43 -0
- data/README.md +5 -5
- data/gemfiles/rails40.gemfile +1 -1
- data/gemfiles/rails41.gemfile +1 -1
- data/gemfiles/rails42.gemfile +1 -1
- data/gemfiles/rails50.gemfile +1 -1
- data/gemfiles/rails51.gemfile +2 -2
- data/gemfiles/rails52.gemfile +8 -0
- data/lib/audited.rb +3 -2
- data/lib/audited/audit.rb +19 -0
- data/lib/audited/auditor.rb +46 -55
- data/lib/audited/rspec_matchers.rb +1 -1
- data/lib/audited/version.rb +1 -1
- data/lib/generators/audited/templates/install.rb +2 -2
- data/lib/generators/audited/templates/revert_polymorphic_indexes_order.rb +20 -0
- data/lib/generators/audited/upgrade_generator.rb +5 -0
- data/spec/audited/audit_spec.rb +22 -0
- data/spec/audited/auditor_spec.rb +23 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/active_record/models.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11243e8bfb9c50162f0f939a283270f7bf706387
|
4
|
+
data.tar.gz: 9b081dea623844e1bd37b71f774490dc8596ef84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5ca8463b13d3c2fc463749a1ff46c1522b5ed6c049dd743e72d47577c5da025f46f3ab90492fa19a88cfbf7cd38ee302e2aefced16098dcd3bd7846a6be0eb9
|
7
|
+
data.tar.gz: e4e5b349f6a8db618deb7a6fd48a853eb75729ddbff3b78c431c89247ec17aaceb2e4a67dd206defbfeb5fe4e8b6a47c4af0212c5898fd777848c08625aca90e
|
data/.travis.yml
CHANGED
@@ -2,9 +2,9 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
4
|
- 2.1
|
5
|
-
- 2.2.
|
6
|
-
- 2.3.
|
7
|
-
- 2.4.
|
5
|
+
- 2.2.8
|
6
|
+
- 2.3.5
|
7
|
+
- 2.4.2
|
8
8
|
- ruby-head
|
9
9
|
env:
|
10
10
|
- DB=SQLITE
|
@@ -18,6 +18,7 @@ gemfile:
|
|
18
18
|
- gemfiles/rails42.gemfile
|
19
19
|
- gemfiles/rails50.gemfile
|
20
20
|
- gemfiles/rails51.gemfile
|
21
|
+
- gemfiles/rails52.gemfile
|
21
22
|
matrix:
|
22
23
|
allow_failures:
|
23
24
|
- rvm: ruby-head
|
@@ -26,9 +27,15 @@ matrix:
|
|
26
27
|
gemfile: gemfiles/rails50.gemfile
|
27
28
|
- rvm: 2.1
|
28
29
|
gemfile: gemfiles/rails51.gemfile
|
29
|
-
- rvm: 2.
|
30
|
+
- rvm: 2.1
|
31
|
+
gemfile: gemfiles/rails52.gemfile
|
32
|
+
- rvm: 2.4.2
|
30
33
|
gemfile: gemfiles/rails40.gemfile
|
31
|
-
- rvm: 2.4.
|
34
|
+
- rvm: 2.4.2
|
35
|
+
gemfile: gemfiles/rails41.gemfile
|
36
|
+
- rvm: ruby-head
|
37
|
+
gemfile: gemfiles/rails40.gemfile
|
38
|
+
- rvm: ruby-head
|
32
39
|
gemfile: gemfiles/rails41.gemfile
|
33
40
|
fast_finish: true
|
34
41
|
branches:
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,49 @@ Fixed
|
|
18
18
|
|
19
19
|
- None
|
20
20
|
|
21
|
+
|
22
|
+
## 4.6.0 (2018-01-10)
|
23
|
+
|
24
|
+
Breaking changes
|
25
|
+
|
26
|
+
- None
|
27
|
+
|
28
|
+
Added
|
29
|
+
|
30
|
+
- Add functionality to undo specific audit
|
31
|
+
[#381](https://github.com/collectiveidea/audited/pull/381)
|
32
|
+
|
33
|
+
Changed
|
34
|
+
|
35
|
+
- Removed duplicate declaration of `non_audited_columns` method
|
36
|
+
[#365](https://github.com/collectiveidea/audited/pull/365)
|
37
|
+
- Updated `audited_changes` calculation to support Rails>=5.1 change syntax
|
38
|
+
[#377](https://github.com/collectiveidea/audited/pull/377)
|
39
|
+
- Improve index ordering for polymorphic indexes
|
40
|
+
[#385](https://github.com/collectiveidea/audited/pull/385)
|
41
|
+
- Update CI to test on newer versions of Ruby and Rails
|
42
|
+
[#386](https://github.com/collectiveidea/audited/pull/386)
|
43
|
+
[#387](https://github.com/collectiveidea/audited/pull/387)
|
44
|
+
[#388](https://github.com/collectiveidea/audited/pull/388)
|
45
|
+
- Simplify `audited_columns` calculation
|
46
|
+
[#391](https://github.com/collectiveidea/audited/pull/391)
|
47
|
+
- Simplify `audited_changes` calculation
|
48
|
+
[#389](https://github.com/collectiveidea/audited/pull/389)
|
49
|
+
- Normalize options passed to `audited` method
|
50
|
+
[#397](https://github.com/collectiveidea/audited/pull/397)
|
51
|
+
|
52
|
+
Fixed
|
53
|
+
|
54
|
+
- Fixed typo in rspec causing incorrect test failure
|
55
|
+
[#360](https://github.com/collectiveidea/audited/pull/360)
|
56
|
+
- Allow running specs using rake
|
57
|
+
[#390](https://github.com/collectiveidea/audited/pull/390)
|
58
|
+
- Passing an invalid version to `revision` returns `nil` instead of last version
|
59
|
+
[#384](https://github.com/collectiveidea/audited/pull/384)
|
60
|
+
- Fix duplicate deceleration warnings
|
61
|
+
[#399](https://github.com/collectiveidea/audited/pull/399)
|
62
|
+
|
63
|
+
|
21
64
|
## 4.5.0 (2017-05-22)
|
22
65
|
|
23
66
|
Breaking changes
|
data/README.md
CHANGED
@@ -11,10 +11,10 @@ For Rails 3, use gem version 3.0 or see the [3.0-stable branch](https://github.c
|
|
11
11
|
|
12
12
|
Audited supports and is [tested against](http://travis-ci.org/collectiveidea/audited) the following Ruby versions:
|
13
13
|
|
14
|
-
* 2.1.
|
15
|
-
* 2.2.
|
16
|
-
* 2.3.
|
17
|
-
* 2.4.
|
14
|
+
* 2.1.10
|
15
|
+
* 2.2.8
|
16
|
+
* 2.3.5
|
17
|
+
* 2.4.2
|
18
18
|
|
19
19
|
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).
|
20
20
|
|
@@ -27,7 +27,7 @@ Audited is currently ActiveRecord-only. In a previous life, Audited worked with
|
|
27
27
|
Add the gem to your Gemfile:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem "audited", "~> 4.
|
30
|
+
gem "audited", "~> 4.6"
|
31
31
|
```
|
32
32
|
|
33
33
|
Then, from your Rails app directory, create the `audits` table:
|
data/gemfiles/rails40.gemfile
CHANGED
data/gemfiles/rails41.gemfile
CHANGED
data/gemfiles/rails42.gemfile
CHANGED
data/gemfiles/rails50.gemfile
CHANGED
data/gemfiles/rails51.gemfile
CHANGED
data/lib/audited.rb
CHANGED
@@ -2,10 +2,11 @@ require 'active_record'
|
|
2
2
|
|
3
3
|
module Audited
|
4
4
|
class << self
|
5
|
-
attr_accessor :ignored_attributes, :current_user_method
|
5
|
+
attr_accessor :ignored_attributes, :current_user_method
|
6
|
+
attr_writer :audit_class
|
6
7
|
|
7
8
|
def audit_class
|
8
|
-
@audit_class
|
9
|
+
@audit_class ||= Audit
|
9
10
|
end
|
10
11
|
|
11
12
|
def store
|
data/lib/audited/audit.rb
CHANGED
@@ -86,6 +86,25 @@ module Audited
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
# Allows user to undo changes
|
90
|
+
def undo
|
91
|
+
model = self.auditable_type.constantize
|
92
|
+
if action == 'create'
|
93
|
+
# destroys a newly created record
|
94
|
+
model.find(auditable_id).destroy!
|
95
|
+
elsif action == 'destroy'
|
96
|
+
# creates a new record with the destroyed record attributes
|
97
|
+
model.create(audited_changes)
|
98
|
+
else
|
99
|
+
# changes back attributes
|
100
|
+
audited_object = model.find(auditable_id)
|
101
|
+
self.audited_changes.each do |k, v|
|
102
|
+
audited_object[k] = v[0]
|
103
|
+
end
|
104
|
+
audited_object.save
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
89
108
|
# Allows user to be set to either a string or an ActiveRecord object
|
90
109
|
# @private
|
91
110
|
def user_as_string=(user)
|
data/lib/audited/auditor.rb
CHANGED
@@ -38,26 +38,29 @@ module Audited
|
|
38
38
|
# don't allow multiple calls
|
39
39
|
return if included_modules.include?(Audited::Auditor::AuditedInstanceMethods)
|
40
40
|
|
41
|
+
extend Audited::Auditor::AuditedClassMethods
|
42
|
+
include Audited::Auditor::AuditedInstanceMethods
|
43
|
+
|
41
44
|
class_attribute :audit_associated_with, instance_writer: false
|
42
45
|
class_attribute :audited_options, instance_writer: false
|
46
|
+
attr_accessor :version, :audit_comment
|
43
47
|
|
44
48
|
self.audited_options = options
|
45
|
-
|
49
|
+
normalize_audited_options
|
46
50
|
|
47
|
-
|
51
|
+
self.audit_associated_with = audited_options[:associated_with]
|
52
|
+
|
53
|
+
if audited_options[:comment_required]
|
48
54
|
validates_presence_of :audit_comment, if: :auditing_enabled
|
49
55
|
before_destroy :require_comment
|
50
56
|
end
|
51
57
|
|
52
|
-
attr_accessor :audit_comment
|
53
|
-
|
54
58
|
has_many :audits, -> { order(version: :asc) }, as: :auditable, class_name: Audited.audit_class.name
|
55
59
|
Audited.audit_class.audited_class_names << to_s
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
before_destroy :audit_destroy if on.empty? || on.include?(:destroy)
|
61
|
+
after_create :audit_create if audited_options[:on].include?(:create)
|
62
|
+
before_update :audit_update if audited_options[:on].include?(:update)
|
63
|
+
before_destroy :audit_destroy if audited_options[:on].include?(:destroy)
|
61
64
|
|
62
65
|
# Define and set after_audit and around_audit callbacks. This might be useful if you want
|
63
66
|
# to notify a party after the audit has been created or if you want to access the newly-created
|
@@ -66,21 +69,12 @@ module Audited
|
|
66
69
|
set_callback :audit, :after, :after_audit, if: lambda { respond_to?(:after_audit, true) }
|
67
70
|
set_callback :audit, :around, :around_audit, if: lambda { respond_to?(:around_audit, true) }
|
68
71
|
|
69
|
-
|
70
|
-
|
71
|
-
extend Audited::Auditor::AuditedClassMethods
|
72
|
-
include Audited::Auditor::AuditedInstanceMethods
|
73
|
-
|
74
|
-
self.auditing_enabled = true
|
72
|
+
enable_auditing
|
75
73
|
end
|
76
74
|
|
77
75
|
def has_associated_audits
|
78
76
|
has_many :associated_audits, as: :associated, class_name: Audited.audit_class.name
|
79
77
|
end
|
80
|
-
|
81
|
-
def default_ignored_attributes
|
82
|
-
[primary_key, inheritance_column]
|
83
|
-
end
|
84
78
|
end
|
85
79
|
|
86
80
|
module AuditedInstanceMethods
|
@@ -109,16 +103,15 @@ module Audited
|
|
109
103
|
def revisions(from_version = 1)
|
110
104
|
audits = self.audits.from_version(from_version)
|
111
105
|
return [] if audits.empty?
|
112
|
-
|
113
|
-
audits.each do |audit|
|
114
|
-
revisions << audit.revision
|
115
|
-
end
|
116
|
-
revisions
|
106
|
+
audits.map(&:revision)
|
117
107
|
end
|
118
108
|
|
119
109
|
# Get a specific revision specified by the version number, or +:previous+
|
110
|
+
# Returns nil for versions greater than revisions count
|
120
111
|
def revision(version)
|
121
|
-
|
112
|
+
if version == :previous || self.audits.last.version >= version
|
113
|
+
revision_with Audited.audit_class.reconstruct_attributes(audits_to(version))
|
114
|
+
end
|
122
115
|
end
|
123
116
|
|
124
117
|
# Find the oldest revision recorded prior to the date/time provided.
|
@@ -129,11 +122,7 @@ module Audited
|
|
129
122
|
|
130
123
|
# List of attributes that are audited.
|
131
124
|
def audited_attributes
|
132
|
-
attributes.except(*non_audited_columns
|
133
|
-
end
|
134
|
-
|
135
|
-
def non_audited_columns
|
136
|
-
self.class.non_audited_columns
|
125
|
+
attributes.except(*non_audited_columns)
|
137
126
|
end
|
138
127
|
|
139
128
|
protected
|
@@ -142,6 +131,10 @@ module Audited
|
|
142
131
|
self.class.non_audited_columns
|
143
132
|
end
|
144
133
|
|
134
|
+
def audited_columns
|
135
|
+
self.class.audited_columns
|
136
|
+
end
|
137
|
+
|
145
138
|
def revision_with(attributes)
|
146
139
|
dup.tap do |revision|
|
147
140
|
revision.id = id
|
@@ -175,17 +168,11 @@ module Audited
|
|
175
168
|
private
|
176
169
|
|
177
170
|
def audited_changes
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
changed_attributes.except(*non_audited_columns)
|
184
|
-
end
|
185
|
-
|
186
|
-
collection.inject({}) do |changes, (attr, old_value)|
|
187
|
-
changes[attr] = [old_value, self[attr]]
|
188
|
-
changes
|
171
|
+
all_changes = respond_to?(:changes_to_save) ? changes_to_save : changes
|
172
|
+
if audited_options[:only].present?
|
173
|
+
all_changes.slice(*audited_columns)
|
174
|
+
else
|
175
|
+
all_changes.except(*non_audited_columns)
|
189
176
|
end
|
190
177
|
end
|
191
178
|
|
@@ -236,9 +223,6 @@ module Audited
|
|
236
223
|
alias_method "#{attr_name}_callback".to_sym, attr_name
|
237
224
|
end
|
238
225
|
|
239
|
-
def empty_callback #:nodoc:
|
240
|
-
end
|
241
|
-
|
242
226
|
def auditing_enabled
|
243
227
|
self.class.auditing_enabled
|
244
228
|
end
|
@@ -251,24 +235,19 @@ module Audited
|
|
251
235
|
module AuditedClassMethods
|
252
236
|
# Returns an array of columns that are audited. See non_audited_columns
|
253
237
|
def audited_columns
|
254
|
-
|
238
|
+
@audited_columns ||= column_names - non_audited_columns
|
255
239
|
end
|
256
240
|
|
241
|
+
# We have to calculate this here since column_names may not be available when `audited` is called
|
257
242
|
def non_audited_columns
|
258
|
-
@non_audited_columns ||=
|
259
|
-
|
260
|
-
|
261
|
-
except = column_names - Array.wrap(options[:only]).flatten.map(&:to_s)
|
262
|
-
else
|
263
|
-
except = default_ignored_attributes + Audited.ignored_attributes
|
264
|
-
except |= Array(options[:except]).collect(&:to_s) if options[:except]
|
265
|
-
end
|
266
|
-
except
|
267
|
-
end
|
243
|
+
@non_audited_columns ||= audited_options[:only].present? ?
|
244
|
+
column_names - audited_options[:only] :
|
245
|
+
default_ignored_attributes | audited_options[:except]
|
268
246
|
end
|
269
247
|
|
270
248
|
def non_audited_columns=(columns)
|
271
|
-
@
|
249
|
+
@audited_columns = nil # reset cached audited columns on assignment
|
250
|
+
@non_audited_columns = columns.map(&:to_s)
|
272
251
|
end
|
273
252
|
|
274
253
|
# Executes the block with auditing disabled.
|
@@ -308,6 +287,18 @@ module Audited
|
|
308
287
|
def auditing_enabled=(val)
|
309
288
|
Audited.store["#{table_name}_auditing_enabled"] = val
|
310
289
|
end
|
290
|
+
|
291
|
+
protected
|
292
|
+
def default_ignored_attributes
|
293
|
+
[primary_key, inheritance_column] + Audited.ignored_attributes
|
294
|
+
end
|
295
|
+
|
296
|
+
def normalize_audited_options
|
297
|
+
audited_options[:on] = Array.wrap(audited_options[:on])
|
298
|
+
audited_options[:on] = [:create, :update, :destroy] if audited_options[:on].empty?
|
299
|
+
audited_options[:only] = Array.wrap(audited_options[:only]).map(&:to_s)
|
300
|
+
audited_options[:except] = Array.wrap(audited_options[:except]).map(&:to_s)
|
301
|
+
end
|
311
302
|
end
|
312
303
|
end
|
313
304
|
end
|
@@ -117,7 +117,7 @@ module Audited
|
|
117
117
|
except |= @options[:except].collect(&:to_s) if @options[:except]
|
118
118
|
end
|
119
119
|
|
120
|
-
expects "non audited columns (#{model_class.non_audited_columns.inspect}) to match (#{
|
120
|
+
expects "non audited columns (#{model_class.non_audited_columns.inspect}) to match (#{except})"
|
121
121
|
model_class.non_audited_columns =~ except
|
122
122
|
else
|
123
123
|
true
|
data/lib/audited/version.rb
CHANGED
@@ -17,8 +17,8 @@ class <%= migration_class_name %> < <%= migration_parent %>
|
|
17
17
|
t.column :created_at, :datetime
|
18
18
|
end
|
19
19
|
|
20
|
-
add_index :audits, [:
|
21
|
-
add_index :audits, [:
|
20
|
+
add_index :audits, [:auditable_type, :auditable_id], :name => 'auditable_index'
|
21
|
+
add_index :audits, [:associated_type, :associated_id], :name => 'associated_index'
|
22
22
|
add_index :audits, [:user_id, :user_type], :name => 'user_index'
|
23
23
|
add_index :audits, :request_uuid
|
24
24
|
add_index :audits, :created_at
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class <%= migration_class_name %> < <%= migration_parent %>
|
2
|
+
def self.up
|
3
|
+
fix_index_order_for [:associated_id, :associated_type], 'associated_index'
|
4
|
+
fix_index_order_for [:auditable_id, :auditable_type], 'auditable_index'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
fix_index_order_for [:associated_type, :associated_id], 'associated_index'
|
9
|
+
fix_index_order_for [:auditable_type, :auditable_id], 'auditable_index'
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def fix_index_order_for(columns, index_name)
|
15
|
+
if index_exists? :audits, columns, name: index_name
|
16
|
+
remove_index :audits, name: index_name
|
17
|
+
add_index :audits, columns.reverse, name: index_name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -25,6 +25,7 @@ module Audited
|
|
25
25
|
def migrations_to_be_applied
|
26
26
|
Audited::Audit.reset_column_information
|
27
27
|
columns = Audited::Audit.columns.map(&:name)
|
28
|
+
indexes = Audited::Audit.connection.indexes(Audited::Audit.table_name)
|
28
29
|
|
29
30
|
yield :add_comment_to_audits unless columns.include?('comment')
|
30
31
|
|
@@ -53,6 +54,10 @@ module Audited
|
|
53
54
|
if columns.include?('association_id')
|
54
55
|
yield :rename_association_to_associated
|
55
56
|
end
|
57
|
+
|
58
|
+
if indexes.any? { |i| i.columns == %w[associated_id associated_type] }
|
59
|
+
yield :revert_polymorphic_indexes_order
|
60
|
+
end
|
56
61
|
end
|
57
62
|
end
|
58
63
|
end
|
data/spec/audited/audit_spec.rb
CHANGED
@@ -38,6 +38,28 @@ describe Audited::Audit do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
it "should undo changes" do
|
42
|
+
user = Models::ActiveRecord::User.create(name: "John")
|
43
|
+
user.update_attribute(:name, 'Joe')
|
44
|
+
user.audits.last.undo
|
45
|
+
user.reload
|
46
|
+
|
47
|
+
expect(user.name).to eq("John")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should undo destroyed model" do
|
51
|
+
user = Models::ActiveRecord::User.create(name: "John")
|
52
|
+
user.destroy
|
53
|
+
user.audits.last.undo
|
54
|
+
user = Models::ActiveRecord::User.find_by(name: "John")
|
55
|
+
expect(user.name).to eq("John")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should undo created model" do
|
59
|
+
user = Models::ActiveRecord::User.create(name: "John")
|
60
|
+
expect {user.audits.last.undo}.to change(Models::ActiveRecord::User, :count).by(-1)
|
61
|
+
end
|
62
|
+
|
41
63
|
context "when a custom audit class is not configured" do
|
42
64
|
it "should default to #{described_class}" do
|
43
65
|
TempModel.audited
|
@@ -60,6 +60,25 @@ describe Audited::Auditor do
|
|
60
60
|
expect(user.audits.last.audited_changes.keys).to eq(%w{password})
|
61
61
|
end
|
62
62
|
|
63
|
+
it "should save attributes not specified in 'except' option" do
|
64
|
+
user = Models::ActiveRecord::User.create
|
65
|
+
user.instance_eval do
|
66
|
+
def non_column_attr
|
67
|
+
@non_column_attr
|
68
|
+
end
|
69
|
+
|
70
|
+
def non_column_attr=(val)
|
71
|
+
attribute_will_change!("non_column_attr")
|
72
|
+
@non_column_attr = val
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
user.password = "password"
|
77
|
+
user.non_column_attr = "some value"
|
78
|
+
user.save!
|
79
|
+
expect(user.audits.last.audited_changes.keys).to eq(%w{non_column_attr})
|
80
|
+
end
|
81
|
+
|
63
82
|
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' && Rails.version >= "4.2.0.0" # Postgres json and jsonb support was added in Rails 4.2
|
64
83
|
describe "'json' and 'jsonb' audited_changes column type" do
|
65
84
|
let(:migrations_path) { SPEC_ROOT.join("support/active_record/postgres") }
|
@@ -452,6 +471,10 @@ describe Audited::Auditor do
|
|
452
471
|
user.revision(1).save!
|
453
472
|
}.to change( Models::ActiveRecord::User, :count ).by(1)
|
454
473
|
end
|
474
|
+
|
475
|
+
it "should return nil for values greater than the number of revisions" do
|
476
|
+
expect(user.revision(user.revisions.count + 1)).to be_nil
|
477
|
+
end
|
455
478
|
end
|
456
479
|
|
457
480
|
describe "revision_at" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
ENV['RAILS_ENV'] = 'test'
|
2
2
|
|
3
|
+
require 'bundler'
|
3
4
|
if Bundler.definition.dependencies.map(&:name).include?('protected_attributes')
|
4
5
|
require 'protected_attributes'
|
5
6
|
end
|
@@ -8,7 +9,6 @@ require 'rspec/rails'
|
|
8
9
|
require 'audited'
|
9
10
|
require 'audited_spec_helpers'
|
10
11
|
require 'support/active_record/models'
|
11
|
-
load "audited/sweeper.rb" # force to reload sweeper
|
12
12
|
|
13
13
|
SPEC_ROOT = Pathname.new(File.expand_path('../', __FILE__))
|
14
14
|
|
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
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- gemfiles/rails42.gemfile
|
146
146
|
- gemfiles/rails50.gemfile
|
147
147
|
- gemfiles/rails51.gemfile
|
148
|
+
- gemfiles/rails52.gemfile
|
148
149
|
- lib/audited-rspec.rb
|
149
150
|
- lib/audited.rb
|
150
151
|
- lib/audited/audit.rb
|
@@ -163,6 +164,7 @@ files:
|
|
163
164
|
- lib/generators/audited/templates/rename_association_to_associated.rb
|
164
165
|
- lib/generators/audited/templates/rename_changes_to_audited_changes.rb
|
165
166
|
- lib/generators/audited/templates/rename_parent_to_association.rb
|
167
|
+
- lib/generators/audited/templates/revert_polymorphic_indexes_order.rb
|
166
168
|
- lib/generators/audited/upgrade_generator.rb
|
167
169
|
- spec/audited/audit_spec.rb
|
168
170
|
- spec/audited/auditor_spec.rb
|
@@ -212,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
214
|
version: '0'
|
213
215
|
requirements: []
|
214
216
|
rubyforge_project:
|
215
|
-
rubygems_version: 2.6.
|
217
|
+
rubygems_version: 2.6.13
|
216
218
|
signing_key:
|
217
219
|
specification_version: 4
|
218
220
|
summary: Log all changes to your models
|