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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bd000e9aee82f6d9bc8f26875cf255276e1c03c4
4
- data.tar.gz: 71228c6fd0026f14f1c79ffc092fa212c680ec12
2
+ SHA256:
3
+ metadata.gz: 91cd155edfaec5e9cbe81994bdc5e12e8fd91b58886d8397a6f310ddade5ae03
4
+ data.tar.gz: 5d7b4f209cf8d8803dff66e4f19b8f85c586373ea757f1e84c1422d56feee1c0
5
5
  SHA512:
6
- metadata.gz: 85c69841d137bc726c684589a1b4ec6e2352fa3f1751cd20c38431f66dd67c459766c842f7582cda9cabfadd235d3c1b2b37548408a23118d14b194ac45e6f1b
7
- data.tar.gz: 1c1a0854e666f9255972563fe2c32bb708fd1f4ad271144d1062a765c22a40d929a8bc2301278ae30bb162d214b19ea24046c35478f10c56af2748ef7205582a
6
+ metadata.gz: 48bab7914ba66c2e7e82bf1bb6936b113b4536ab1297e9d8cdad80036788506bc825594daf37d308b8acbff3321e7ea1936fe6bdb3481f48f311a8caaec9e4ec
7
+ data.tar.gz: f30cdcce78fd2c9202d3147af5d6e6844fb77f5e81300b79261d29f0d931580e67dd3bb04799d0247d3a8b4893314996a05d3ff25d477c43dbc3cf713ecd59fd
data/.gitignore CHANGED
@@ -9,7 +9,6 @@
9
9
  .ruby-version
10
10
  .rvmrc
11
11
  .yardoc
12
- coverage/
13
12
  doc/
14
13
  Gemfile.lock
15
14
  gemfiles/*.lock
@@ -0,0 +1,25 @@
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
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.1
5
- - 2.2.9
6
- - 2.3.6
7
- - 2.4.3
8
- - 2.5.0
4
+ - 2.3.7
5
+ - 2.4.4
6
+ - 2.5.1
7
+ - 2.6.3
9
8
  - ruby-head
10
9
  env:
11
10
  - DB=SQLITE
@@ -13,44 +12,45 @@ env:
13
12
  - DB=MYSQL
14
13
  addons:
15
14
  postgresql: "9.4"
15
+ services:
16
+ - mysql
16
17
  before_install:
17
18
  # https://github.com/travis-ci/travis-ci/issues/8978
18
19
  - "travis_retry gem update --system"
19
- - "travis_retry gem install bundler"
20
+ # Rails 4.2 has a bundler 1.x requirement
21
+ - if [ $BUNDLE_GEMFILE = $PWD/gemfiles/rails42.gemfile ]; then
22
+ rvm @global do gem uninstall bundler -a -x;
23
+ travis_retry gem install -v '< 2.0.0' bundler;
24
+ else
25
+ travis_retry gem install bundler;
26
+ fi
20
27
  gemfile:
21
- - gemfiles/rails40.gemfile
22
- - gemfiles/rails41.gemfile
23
28
  - gemfiles/rails42.gemfile
24
29
  - gemfiles/rails50.gemfile
25
30
  - gemfiles/rails51.gemfile
26
31
  - gemfiles/rails52.gemfile
32
+ - gemfiles/rails60.gemfile
27
33
  matrix:
28
- allow_failures:
29
- - rvm: ruby-head
34
+ include:
35
+ - rvm: 2.6.3
36
+ script: bundle exec rubocop --parallel
37
+ env: DB=rubocop # make travis build display nicer
30
38
  exclude:
31
- - rvm: 2.1
32
- gemfile: gemfiles/rails50.gemfile
33
- - rvm: 2.1
34
- gemfile: gemfiles/rails51.gemfile
35
- - rvm: 2.1
36
- gemfile: gemfiles/rails52.gemfile
37
- - rvm: 2.4.3
38
- gemfile: gemfiles/rails40.gemfile
39
- - rvm: 2.4.3
40
- gemfile: gemfiles/rails41.gemfile
41
- - rvm: 2.5.0
42
- gemfile: gemfiles/rails40.gemfile
43
- - rvm: 2.5.0
44
- gemfile: gemfiles/rails41.gemfile
39
+ - rvm: 2.3.7
40
+ gemfile: gemfiles/rails60.gemfile
41
+ - rvm: 2.4.4
42
+ gemfile: gemfiles/rails60.gemfile
43
+ - rvm: 2.6.3
44
+ gemfile: gemfiles/rails42.gemfile
45
45
  - rvm: ruby-head
46
- gemfile: gemfiles/rails40.gemfile
46
+ gemfile: gemfiles/rails42.gemfile
47
+ allow_failures:
47
48
  - rvm: ruby-head
48
- gemfile: gemfiles/rails41.gemfile
49
49
  fast_finish: true
50
50
  branches:
51
51
  only:
52
52
  - master
53
- sudo: false
53
+ - /.*-stable$/
54
54
  notifications:
55
55
  webhooks:
56
56
  urls:
data/Appraisals CHANGED
@@ -1,28 +1,38 @@
1
- appraise 'rails40' do
2
- gem 'rails', '~> 4.0.0'
3
- gem 'protected_attributes'
4
- gem 'test-unit'
5
- end
6
-
7
- appraise 'rails41' do
8
- gem 'rails', '~> 4.1.0'
9
- gem 'protected_attributes'
10
- end
1
+ # Include DB adapters matching the version requirements in
2
+ # rails/activerecord/lib/active_record/connection_adapters/*adapter.rb
11
3
 
12
4
  appraise 'rails42' do
13
5
  gem 'rails', '~> 4.2.0'
14
6
  gem 'protected_attributes'
7
+ gem "mysql2", ">= 0.3.13", "< 0.6.0"
8
+ gem "pg", "~> 0.15"
9
+ gem "sqlite3", "~> 1.3.6"
15
10
  end
16
11
 
17
12
  appraise 'rails50' do
18
13
  gem 'rails', '~> 5.0.0'
14
+ gem "mysql2", ">= 0.3.18", "< 0.6.0"
15
+ gem "pg", ">= 0.18", "< 2.0"
16
+ gem "sqlite3", "~> 1.3.6"
19
17
  end
20
18
 
21
19
  appraise 'rails51' do
22
20
  gem 'rails', '~> 5.1.4'
21
+ gem "mysql2", ">= 0.3.18", "< 0.6.0"
22
+ gem "pg", ">= 0.18", "< 2.0"
23
+ gem "sqlite3", "~> 1.3.6"
23
24
  end
24
25
 
25
26
  appraise 'rails52' do
26
27
  gem 'rails', '>= 5.2.0', '< 5.3'
27
- gem 'mysql2', '~> 0.4.4'
28
+ gem "mysql2", ">= 0.4.4", "< 0.6.0"
29
+ gem "pg", ">= 0.18", "< 2.0"
30
+ gem "sqlite3", "~> 1.3.6"
31
+ end
32
+
33
+ appraise 'rails60' do
34
+ gem 'rails', '>= 6.0.0.rc1', '< 6.1'
35
+ gem "mysql2", ">= 0.4.4"
36
+ gem "pg", ">= 0.18", "< 2.0"
37
+ gem "sqlite3", "~> 1.4"
28
38
  end
@@ -1,5 +1,37 @@
1
1
  # Audited ChangeLog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 4.9.0 (2019-07-17)
6
+
7
+ Breaking changes
8
+
9
+ - removed block support for `Audit.reconstruct_attributes`
10
+ [#437](https://github.com/collectiveidea/audited/pull/437)
11
+ - removed `audited_columns`, `non_audited_columns`, `auditing_enabled=` instance methods,
12
+ use class methods instead
13
+ [#424](https://github.com/collectiveidea/audited/pull/424)
14
+ - removed rails 4.1 and 4.0 support
15
+ [#431](https://github.com/collectiveidea/audited/pull/431)
16
+
17
+ Added
18
+
19
+ - Add `with_auditing` methods to enable temporarily
20
+ [#502](https://github.com/collectiveidea/audited/pull/502)
21
+ - Add `update_with_comment_only` option to control audit creation with only comments
22
+ [#327](https://github.com/collectiveidea/audited/pull/327)
23
+ - Support for Rails 6.0 and Ruby 2.6
24
+ [#494](https://github.com/collectiveidea/audited/pull/494)
25
+
26
+ Changed
27
+
28
+ - None
29
+
30
+ Fixed
31
+
32
+ - Ensure enum changes are stored consistently
33
+ [#429](https://github.com/collectiveidea/audited/pull/429)
34
+
3
35
  ## 4.8.0 (2018-08-19)
4
36
 
5
37
  Breaking changes
@@ -26,7 +58,7 @@ Changed
26
58
 
27
59
  Fixed
28
60
 
29
- - None
61
+ - None
30
62
 
31
63
  ## 4.7.1 (2018-04-10)
32
64
 
@@ -40,8 +72,7 @@ Added
40
72
 
41
73
  Changed
42
74
 
43
- - Change/deprecate `version` attribute to `audit_version` attribute
44
- [#443](https://github.com/collectiveidea/audited/pull/443)
75
+ - None
45
76
 
46
77
  Fixed
47
78
 
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
- Audited [![Build Status](https://secure.travis-ci.org/collectiveidea/audited.svg)](http://travis-ci.org/collectiveidea/audited) [![Dependency Status](https://gemnasium.com/collectiveidea/audited.svg)](https://gemnasium.com/collectiveidea/audited)[![Code Climate](https://codeclimate.com/github/collectiveidea/audited.svg)](https://codeclimate.com/github/collectiveidea/audited) [![Security](https://hakiri.io/github/collectiveidea/audited/master.svg)](https://hakiri.io/github/collectiveidea/audited/master)
1
+ Audited [![Build Status](https://secure.travis-ci.org/collectiveidea/audited.svg)](http://travis-ci.org/collectiveidea/audited) [![Code Climate](https://codeclimate.com/github/collectiveidea/audited.svg)](https://codeclimate.com/github/collectiveidea/audited) [![Security](https://hakiri.io/github/collectiveidea/audited/master.svg)](https://hakiri.io/github/collectiveidea/audited/master)
2
2
  =======
3
3
 
4
4
  **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.
5
5
 
6
- Audited currently (4.x) works with Rails 5.2, 5.1, 5.0 and 4.2. It may work with 4.1 and 4.0, but this is not guaranteed.
6
+ Audited currently (4.x) works with Rails 6.0, 5.2, 5.1, 5.0 and 4.2.
7
7
 
8
8
  For Rails 3, use gem version 3.0 or see the [3.0-stable branch](https://github.com/collectiveidea/audited/tree/3.0-stable).
9
9
 
@@ -11,11 +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.10
15
- * 2.2.9
16
- * 2.3.6
17
- * 2.4.3
18
- * 2.5.0
14
+ * 2.3.7
15
+ * 2.4.4
16
+ * 2.5.1
17
+ * 2.6.3
19
18
 
20
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).
21
20
 
@@ -28,7 +27,7 @@ Audited is currently ActiveRecord-only. In a previous life, Audited worked with
28
27
  Add the gem to your Gemfile:
29
28
 
30
29
  ```ruby
31
- gem "audited", "~> 4.7"
30
+ gem "audited", "~> 4.9"
32
31
  ```
33
32
 
34
33
  Then, from your Rails app directory, create the `audits` table:
@@ -38,7 +37,9 @@ $ rails generate audited:install
38
37
  $ rake db:migrate
39
38
  ```
40
39
 
41
- If you're using PostgreSQL, then you can use `rails generate audited:install --audited-changes-column-type jsonb` (or `json`) to store audit changes natively with its JSON column types. If you're using something other than integer primary keys (e.g. UUID) for your User model, then you can use `rails generate audited:install --audited-user-id-column-type uuid` to customize the `audits` table `user_id` column type.
40
+ By default changes are stored in YAML format. If you're using PostgreSQL, then you can use `rails generate audited:install --audited-changes-column-type jsonb` (or `json` for MySQL 5.7+ and Rails 5+) to store audit changes natively with database JSON column types.
41
+
42
+ If you're using something other than integer primary keys (e.g. UUID) for your User model, then you can use `rails generate audited:install --audited-user-id-column-type uuid` to customize the `audits` table `user_id` column type.
42
43
 
43
44
  #### Upgrading
44
45
 
@@ -67,7 +68,7 @@ By default, whenever a user is created, updated or destroyed, a new audit is cre
67
68
  ```ruby
68
69
  user = User.create!(name: "Steve")
69
70
  user.audits.count # => 1
70
- user.update_attributes!(name: "Ryan")
71
+ user.update!(name: "Ryan")
71
72
  user.audits.count # => 2
72
73
  user.destroy
73
74
  user.audits.count # => 3
@@ -76,7 +77,7 @@ user.audits.count # => 3
76
77
  Audits contain information regarding what action was taken on the model and what changes were made.
77
78
 
78
79
  ```ruby
79
- user.update_attributes!(name: "Ryan")
80
+ user.update!(name: "Ryan")
80
81
  audit = user.audits.last
81
82
  audit.action # => "update"
82
83
  audit.audited_changes # => {"name"=>["Steve", "Ryan"]}
@@ -130,7 +131,7 @@ end
130
131
  You can attach comments to each audit using an `audit_comment` attribute on your model.
131
132
 
132
133
  ```ruby
133
- user.update_attributes!(name: "Ryan", audit_comment: "Changing name, just because")
134
+ user.update!(name: "Ryan", audit_comment: "Changing name, just because")
134
135
  user.audits.last.comment # => "Changing name, just because"
135
136
  ```
136
137
 
@@ -142,6 +143,14 @@ class User < ActiveRecord::Base
142
143
  end
143
144
  ```
144
145
 
146
+ You can update an audit if only audit_comment is present. You can optionally add the `:update_with_comment_only` option set to `false` to your `audited` call to turn this behavior off for all audits.
147
+
148
+ ```ruby
149
+ class User < ActiveRecord::Base
150
+ audited :update_with_comment_only => false
151
+ end
152
+ ```
153
+
145
154
  ### Limiting stored audits
146
155
 
147
156
  You can limit the number of audits stored for your model. To configure limiting for all audited models, put the following in an initializer:
@@ -163,7 +172,7 @@ Whenever an object is updated or destroyed, extra audits are combined with newer
163
172
  ```ruby
164
173
  user = User.create!(name: "Steve")
165
174
  user.audits.count # => 1
166
- user.update_attributes!(name: "Ryan")
175
+ user.update!(name: "Ryan")
167
176
  user.audits.count # => 2
168
177
  user.destroy
169
178
  user.audits.count # => 2
@@ -193,16 +202,16 @@ Outside of a request, Audited can still record the user with the `as_user` metho
193
202
 
194
203
  ```ruby
195
204
  Audited.audit_class.as_user(User.find(1)) do
196
- post.update_attributes!(title: "Hello, world!")
205
+ post.update!(title: "Hello, world!")
197
206
  end
198
207
  post.audits.last.user # => #<User id: 1>
199
208
  ```
200
209
 
201
210
  The standard Audited install assumes your User model has an integer primary key type. If this isn't true (e.g. you're using UUID primary keys), you'll need to create a migration to update the `audits` table `user_id` column type. (See Installation above for generator flags if you'd like to regenerate the install migration.)
202
211
 
203
- #### Custom Auditor
212
+ #### Custom Audit User
204
213
 
205
- You might need to use a custom auditor from time to time. It can be done by simply passing in a string:
214
+ You might need to use a custom auditor from time to time. This can be done by simply passing in a string:
206
215
 
207
216
  ```ruby
208
217
  class ApplicationController < ActionController::Base
@@ -216,6 +225,15 @@ class ApplicationController < ActionController::Base
216
225
  end
217
226
  ```
218
227
 
228
+ `as_user` also accepts a string, which can be useful for auditing updates made in a CLI environment:
229
+
230
+ ```rb
231
+ Audited.audit_class.as_user("console-user-#{ENV['SSH_USER']}") do
232
+ post.update_attributes!(title: "Hello, world!")
233
+ end
234
+ post.audits.last.user # => 'console-user-username'
235
+ ```
236
+
219
237
  ### Associated Audits
220
238
 
221
239
  Sometimes it's useful to associate an audit with a model other than the one being changed. For instance, given the following models:
@@ -250,7 +268,7 @@ Now, when an audit is created for a user, that user's company is also saved alon
250
268
  ```ruby
251
269
  company = Company.create!(name: "Collective Idea")
252
270
  user = company.users.create!(name: "Steve")
253
- user.update_attribute!(name: "Steve Richert")
271
+ user.update!(name: "Steve Richert")
254
272
  user.audits.last.associated # => #<Company name: "Collective Idea">
255
273
  company.associated_audits.last.auditable # => #<User name: "Steve Richert">
256
274
  ```
@@ -323,6 +341,23 @@ To disable auditing on all models:
323
341
  Audited.auditing_enabled = false
324
342
  ```
325
343
 
344
+ If you have auditing disabled by default on your model you can enable auditing
345
+ temporarily.
346
+
347
+ ```ruby
348
+ User.auditing_enabled = false
349
+ @user.save_with_auditing
350
+ ```
351
+
352
+ or:
353
+
354
+ ```ruby
355
+ User.auditing_enabled = false
356
+ @user.with_auditing do
357
+ @user.save
358
+ end
359
+ ```
360
+
326
361
  ### Custom `Audit` model
327
362
 
328
363
  If you want to extend or modify the audit model, create a new class that
@@ -4,5 +4,8 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4.2.0"
6
6
  gem "protected_attributes"
7
+ gem "mysql2", ">= 0.3.13", "< 0.6.0"
8
+ gem "pg", "~> 0.15"
9
+ gem "sqlite3", "~> 1.3.6"
7
10
 
8
11
  gemspec name: "audited", path: "../"
@@ -3,5 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
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"
6
9
 
7
10
  gemspec name: "audited", path: "../"
@@ -3,5 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.1.4"
6
+ gem "mysql2", ">= 0.3.18", "< 0.6.0"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.3.6"
6
9
 
7
10
  gemspec name: "audited", path: "../"
@@ -3,6 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", ">= 5.2.0", "< 5.3"
6
- gem "mysql2", "~> 0.4.4"
6
+ gem "mysql2", ">= 0.4.4", "< 0.6.0"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.3.6"
7
9
 
8
10
  gemspec name: "audited", path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", ">= 6.0.0.rc1", "< 6.1"
6
+ gem "mysql2", ">= 0.4.4"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.4"
9
+
10
+ gemspec name: "audited", path: "../"