audit_record 0.1.1 → 0.1.2
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.
- data/README.rdoc +0 -3
- data/VERSION +1 -1
- data/audit_record.gemspec +3 -3
- data/lib/{audit.rb → audit_record.rb} +0 -0
- data/lib/auditable/audit_record.rb +2 -0
- data/test/audit_test.rb +11 -0
- data/test/helper.rb +12 -1
- metadata +4 -4
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/audit_record.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "audit_record"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark Daggett"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-04-20"
|
13
13
|
s.description = "A simple gem built for Rails 3+ which creates an audit when events that you configure occur. The events you can audit are:\n\n 1. Attributes changing in a model\n 2. Methods called on a model\n 3. Methods called on some other class like a controller.\n"
|
14
14
|
s.email = "mark@humansized.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"audit_record.gemspec",
|
28
|
-
"lib/
|
28
|
+
"lib/audit_record.rb",
|
29
29
|
"lib/auditable/audit_record.rb",
|
30
30
|
"lib/auditable/audit_record_sweeper.rb",
|
31
31
|
"lib/auditable/auditor.rb",
|
File without changes
|
@@ -16,6 +16,8 @@
|
|
16
16
|
class AuditRecord < ActiveRecord::Base
|
17
17
|
serialize :modifications
|
18
18
|
belongs_to :user
|
19
|
+
attr_accessible :action, :auditable_id, :auditable_type, :modifications, :remote_address, :user_id
|
20
|
+
|
19
21
|
class << self
|
20
22
|
def create_for(record)
|
21
23
|
unless record.audited_attribute_changes.empty?
|
data/test/audit_test.rb
CHANGED
@@ -29,4 +29,15 @@ class AuditTest < ActiveSupport::TestCase
|
|
29
29
|
assert_equal(@user.id, @a.auditable_id)
|
30
30
|
assert_equal("User.destroy was called",@a.action)
|
31
31
|
end
|
32
|
+
should "support :attributes => true to audit all attributes"
|
33
|
+
should "support :attributes => %w(foo bar baz)"
|
34
|
+
should "support :attributes => { :fields => %w(foo bar baz) }"
|
35
|
+
should "support :attributes => { :fields => %w(foo bar baz) :if => Proc.new {|a| a == b} }"
|
36
|
+
should "support :attributes => { :fields => %w(foo bar baz) :unless => Proc.new {|a| a != b} }"
|
37
|
+
should "support :methods => true"
|
38
|
+
should "support :methods => %w(save destroy update create)"
|
39
|
+
should "support :methods => { :in => %w(foo bar baz) }"
|
40
|
+
should "support :methods => { :in => %w(foo bar baz), :if => Proc.new {|a| a == b} }"
|
41
|
+
should "support :methods => { :in => %w(foo bar baz), :unless => Proc.new {|a| a == b} }"
|
42
|
+
should "allow the model to be reverted back to values in the model"
|
32
43
|
end
|
data/test/helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'bundler'
|
3
3
|
require 'rails'
|
4
4
|
require 'active_record'
|
5
|
+
require 'ruby-debug'
|
5
6
|
begin
|
6
7
|
Bundler.setup(:default, :development)
|
7
8
|
rescue Bundler::BundlerError => e
|
@@ -14,7 +15,7 @@ require 'shoulda'
|
|
14
15
|
|
15
16
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
17
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
-
require '
|
18
|
+
require 'audit_record'
|
18
19
|
|
19
20
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
20
21
|
|
@@ -23,6 +24,11 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
23
24
|
t.string :name
|
24
25
|
t.boolean :is_admin, :default => false
|
25
26
|
end
|
27
|
+
|
28
|
+
create_table :comments, :force => true do |t|
|
29
|
+
t.string :body
|
30
|
+
end
|
31
|
+
|
26
32
|
create_table "audit_records", :force => true do |t|
|
27
33
|
t.integer "user_id"
|
28
34
|
t.string "action"
|
@@ -41,6 +47,11 @@ end
|
|
41
47
|
class User < ActiveRecord::Base
|
42
48
|
audit :methods => [:destroy], :attributes => [:is_admin]
|
43
49
|
end
|
50
|
+
|
51
|
+
class Comment < ActiveRecord::Base
|
52
|
+
audit :attributes => [:name]
|
53
|
+
end
|
54
|
+
|
44
55
|
class ActiveSupport::TestCase
|
45
56
|
fixtures :all
|
46
57
|
self.use_transactional_fixtures = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audit_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
@@ -286,7 +286,7 @@ files:
|
|
286
286
|
- Rakefile
|
287
287
|
- VERSION
|
288
288
|
- audit_record.gemspec
|
289
|
-
- lib/
|
289
|
+
- lib/audit_record.rb
|
290
290
|
- lib/auditable/audit_record.rb
|
291
291
|
- lib/auditable/audit_record_sweeper.rb
|
292
292
|
- lib/auditable/auditor.rb
|
@@ -309,7 +309,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '0'
|
310
310
|
segments:
|
311
311
|
- 0
|
312
|
-
hash:
|
312
|
+
hash: 697361632597582040
|
313
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
314
|
none: false
|
315
315
|
requirements:
|