audited 4.2.0 → 4.2.1

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
2
  SHA1:
3
- metadata.gz: e008bd8e45b0c84dac31af4c65d41e61b6f76c1f
4
- data.tar.gz: 90ead5b1d9033c3426a20de46ea1aca59798b7ab
3
+ metadata.gz: ef445618f1f48df1d878ae87852c0e1e7aef006c
4
+ data.tar.gz: 56909bce46025423bc70073c87e0f6b729784ab9
5
5
  SHA512:
6
- metadata.gz: 33bd73a0be9da10924353681e4cccb3515dcd5ad9f47f3140ca18914532eef791f3b1c34caa11bb9dd47bd1be34f56751e5457b3946af70ccd20747f9c1215ce
7
- data.tar.gz: bf7c70b57abf23809d08c899558f9a0effc393e2e1d526dcbc45c70f2302c6da96efa409506b6033e8ad87d0d13e97958d3a6515e1f23dd09cd12bb0a73ad4f0
6
+ metadata.gz: 85ddd879a1aaa2cb45dbca5aeea09d2837c6b25d2dd19978c4d6c3b3df072d3e2ce826a383bbcfa982cd2e3a993cf8b874f0914119bb6bbe3cb2e31969bb2b02
7
+ data.tar.gz: ab035d36a69f7cc87cec3dca57d407d5301db967d189a0e16c42eaef906ee1d9e212beebe7ffe20565e9a7e7ac613b20fa28972182bbe79f0b2501218d229d2a
@@ -22,9 +22,10 @@ matrix:
22
22
  branches:
23
23
  only:
24
24
  - master
25
+ - 4.2-stable
25
26
  sudo: false
26
27
  notifications:
27
28
  webhooks:
28
29
  urls:
29
30
  - http://buildlight.collectiveidea.com/
30
- on_start: true
31
+ on_start: always
data/Appraisals CHANGED
@@ -2,14 +2,17 @@ appraise 'rails40' do
2
2
  gem 'rails', '~> 4.0.0'
3
3
  gem 'rails-observers'
4
4
  gem 'test-unit'
5
+ gem 'mysql2', '~> 0.3.0'
5
6
  end
6
7
 
7
8
  appraise 'rails41' do
8
9
  gem 'rails', '~> 4.1.0'
9
10
  gem 'rails-observers'
11
+ gem 'mysql2', '~> 0.3.0'
10
12
  end
11
13
 
12
14
  appraise 'rails42' do
13
15
  gem 'rails', '~> 4.2.0'
14
16
  gem 'rails-observers'
17
+ gem 'mysql2', '~> 0.4.0'
15
18
  end
data/Gemfile CHANGED
@@ -1,3 +1,15 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec :name => 'audited'
4
+ # JRuby support for the test ENV
5
+ unless defined?(JRUBY_VERSION)
6
+ gem 'sqlite3', '~> 1.2'
7
+ gem 'mysql2', '~> 0.3'
8
+ gem 'pg', '~> 0.17'
9
+ gem 'bson_ext', '~> 1.6'
10
+ else
11
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3'
12
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3'
13
+ gem 'activerecord-jdbcmysql-adapter', '~> 1.3'
14
+ gem 'bson', '~> 1.6'
15
+ end
data/README.md CHANGED
@@ -71,9 +71,9 @@ end
71
71
  By default, whenever a user is created, updated or destroyed, a new audit is created.
72
72
 
73
73
  ```ruby
74
- user = User.create!(:name => "Steve")
74
+ user = User.create!(name: "Steve")
75
75
  user.audits.count # => 1
76
- user.update_attributes!(:name => "Ryan")
76
+ user.update_attributes!(name: "Ryan")
77
77
  user.audits.count # => 2
78
78
  user.destroy
79
79
  user.audits.count # => 3
@@ -82,7 +82,7 @@ user.audits.count # => 3
82
82
  Audits contain information regarding what action was taken on the model and what changes were made.
83
83
 
84
84
  ```ruby
85
- user.update_attributes!(:name => "Ryan")
85
+ user.update_attributes!(name: "Ryan")
86
86
  audit = user.audits.last
87
87
  audit.action # => "update"
88
88
  audit.audited_changes # => {"name"=>["Steve", "Ryan"]}
@@ -127,7 +127,7 @@ end
127
127
  You can attach comments to each audit using an `audit_comment` attribute on your model.
128
128
 
129
129
  ```ruby
130
- user.update_attributes!(:name => "Ryan", :audit_comment => "Changing name, just because")
130
+ user.update_attributes!(name: "Ryan", audit_comment: "Changing name, just because")
131
131
  user.audits.last.comment # => "Changing name, just because"
132
132
  ```
133
133
 
@@ -163,7 +163,7 @@ Outside of a request, Audited can still record the user with the `as_user` metho
163
163
 
164
164
  ```ruby
165
165
  Audited.audit_class.as_user(User.find(1)) do
166
- post.update_attribute!(:title => "Hello, world!")
166
+ post.update_attribute!(title: "Hello, world!")
167
167
  end
168
168
  post.audits.last.user # => #<User id: 1>
169
169
  ```
@@ -188,7 +188,7 @@ Every change to a user is audited, but what if you want to grab all of the audit
188
188
  ```ruby
189
189
  class User < ActiveRecord::Base
190
190
  belongs_to :company
191
- audited :associated_with => :company
191
+ audited associated_with: :company
192
192
  end
193
193
 
194
194
  class Company < ActiveRecord::Base
@@ -200,9 +200,9 @@ end
200
200
  Now, when a audit is created for a user, that user's company is also saved alongside the audit. This makes it much easier (and faster) to access audits indirectly related to a company.
201
201
 
202
202
  ```ruby
203
- company = Company.create!(:name => "Collective Idea")
204
- user = company.users.create!(:name => "Steve")
205
- user.update_attribute!(:name => "Steve Richert")
203
+ company = Company.create!(name: "Collective Idea")
204
+ user = company.users.create!(name: "Steve")
205
+ user.update_attribute!(name: "Steve Richert")
206
206
  user.audits.last.associated # => #<Company name: "Collective Idea">
207
207
  company.associated_audits.last.auditable # => #<User name: "Steve Richert">
208
208
  ```
@@ -247,20 +247,20 @@ Audited assumes you are using `attr_accessible`. If you're using
247
247
  two.
248
248
 
249
249
 
250
- If you're using `strong_parameters` with Rails 3.x, be sure to add `:allow_mass_assignment => true` to your `audited` call; otherwise Audited will
250
+ If you're using `strong_parameters` with Rails 3.x, be sure to add `allow_mass_assignment: true` to your `audited` call; otherwise Audited will
251
251
  interfere with `strong_parameters` and none of your `save` calls will work.
252
252
 
253
253
  ```ruby
254
254
  class User < ActiveRecord::Base
255
- audited :allow_mass_assignment => true
255
+ audited allow_mass_assignment: true
256
256
  end
257
257
  ```
258
258
 
259
- If using `attr_protected`, add `:allow_mass_assignment => true`, and also be sure to add `audit_ids` to the list of protected attributes to prevent data loss.
259
+ If using `attr_protected`, add `allow_mass_assignment: true`, and also be sure to add `audit_ids` to the list of protected attributes to prevent data loss.
260
260
 
261
261
  ```ruby
262
262
  class User < ActiveRecord::Base
263
- audited :allow_mass_assignment => true
263
+ audited allow_mass_assignment: true
264
264
  attr_protected :logins, :audit_ids
265
265
  end
266
266
  ```
@@ -2,6 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "sqlite3", "~> 1.2"
6
+ gem "mysql2", "~> 0.3.0"
7
+ gem "pg", "~> 0.17"
8
+ gem "bson_ext", "~> 1.6"
5
9
  gem "rails", "~> 4.0.0"
6
10
  gem "rails-observers"
7
11
  gem "test-unit"
@@ -2,6 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "sqlite3", "~> 1.2"
6
+ gem "mysql2", "~> 0.3.0"
7
+ gem "pg", "~> 0.17"
8
+ gem "bson_ext", "~> 1.6"
5
9
  gem "rails", "~> 4.1.0"
6
10
  gem "rails-observers"
7
11
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "sqlite3", "~> 1.2"
6
+ gem "mysql2", "~> 0.4.0"
7
+ gem "pg", "~> 0.17"
8
+ gem "bson_ext", "~> 1.6"
5
9
  gem "rails", "~> 4.2.0"
6
10
  gem "rails-observers"
7
11
 
@@ -1,5 +1,5 @@
1
1
  module Audited
2
2
  module ActiveRecord
3
- VERSION = "4.2.0"
3
+ VERSION = "4.2.1"
4
4
  end
5
5
  end
@@ -39,11 +39,10 @@ module Audited
39
39
  return if self.included_modules.include?(Audited::Auditor::AuditedInstanceMethods)
40
40
 
41
41
  class_attribute :non_audited_columns, :instance_writer => false
42
- class_attribute :auditing_enabled, :instance_writer => false
43
42
  class_attribute :audit_associated_with, :instance_writer => false
44
43
 
45
44
  if options[:only]
46
- except = self.column_names - options[:only].flatten.map(&:to_s)
45
+ except = self.column_names - Array(options[:only]).flatten.map(&:to_s)
47
46
  else
48
47
  except = default_ignored_attributes + Audited.ignored_attributes
49
48
  except |= Array(options[:except]).collect(&:to_s) if options[:except]
@@ -224,6 +223,14 @@ module Audited
224
223
  def empty_callback #:nodoc:
225
224
  end
226
225
 
226
+ def auditing_enabled
227
+ self.class.auditing_enabled
228
+ end
229
+
230
+ def auditing_enabled= val
231
+ self.class.auditing_enabled = val
232
+ end
233
+
227
234
  end # InstanceMethods
228
235
 
229
236
  module AuditedClassMethods
@@ -261,6 +268,14 @@ module Audited
261
268
  def audit_as( user, &block )
262
269
  Audited.audit_class.as_user( user, &block )
263
270
  end
271
+
272
+ def auditing_enabled
273
+ Audited.store.fetch("#{name.tableize}_auditing_enabled", true)
274
+ end
275
+
276
+ def auditing_enabled= val
277
+ Audited.store["#{name.tableize}_auditing_enabled"] = val
278
+ end
264
279
  end
265
280
  end
266
281
  end
@@ -1,5 +1,5 @@
1
1
  module Audited
2
2
  module MongoMapper
3
- VERSION = "4.2.0"
3
+ VERSION = "4.2.1"
4
4
  end
5
5
  end
@@ -30,8 +30,10 @@ module Audited
30
30
  end
31
31
 
32
32
  def add_observer!(klass)
33
- super
34
- define_callback(klass)
33
+ if defined?(::ActiveRecord)
34
+ super
35
+ define_callback(klass)
36
+ end
35
37
  end
36
38
 
37
39
  def define_callback(klass)
@@ -1,3 +1,3 @@
1
1
  module Audited
2
- VERSION = "4.2.0"
2
+ VERSION = "4.2.1"
3
3
  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.2.0
4
+ version: 4.2.1
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: 2015-03-31 00:00:00.000000000 Z
16
+ date: 2016-07-29 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails-observers
@@ -99,62 +99,6 @@ dependencies:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
101
  version: '3.0'
102
- - !ruby/object:Gem::Dependency
103
- name: sqlite3
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '1.2'
109
- type: :development
110
- prerelease: false
111
- version_requirements: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: '1.2'
116
- - !ruby/object:Gem::Dependency
117
- name: mysql2
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: '0.3'
123
- type: :development
124
- prerelease: false
125
- version_requirements: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '0.3'
130
- - !ruby/object:Gem::Dependency
131
- name: pg
132
- requirement: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: '0.17'
137
- type: :development
138
- prerelease: false
139
- version_requirements: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - "~>"
142
- - !ruby/object:Gem::Version
143
- version: '0.17'
144
- - !ruby/object:Gem::Dependency
145
- name: bson_ext
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - "~>"
149
- - !ruby/object:Gem::Version
150
- version: '1.6'
151
- type: :development
152
- prerelease: false
153
- version_requirements: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - "~>"
156
- - !ruby/object:Gem::Version
157
- version: '1.6'
158
102
  description: Log all changes to your models
159
103
  email: info@collectiveidea.com
160
104
  executables: []
@@ -226,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
170
  version: '0'
227
171
  requirements: []
228
172
  rubyforge_project:
229
- rubygems_version: 2.4.6
173
+ rubygems_version: 2.5.1
230
174
  signing_key:
231
175
  specification_version: 4
232
176
  summary: Log all changes to your models