audit 0.1.0 → 0.2.0
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/audit.gemspec +2 -2
- data/lib/audit.rb +1 -1
- data/lib/audit/tracking.rb +13 -0
- data/test/tracking_test.rb +13 -8
- metadata +3 -3
data/audit.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'audit'
|
16
|
-
s.version = '0.
|
17
|
-
s.date = '2010-
|
16
|
+
s.version = '0.2.0'
|
17
|
+
s.date = '2010-10-05'
|
18
18
|
s.rubyforge_project = 'audit'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/audit.rb
CHANGED
data/lib/audit/tracking.rb
CHANGED
@@ -28,6 +28,11 @@ module Audit::Tracking
|
|
28
28
|
#
|
29
29
|
# Returns nothing.
|
30
30
|
def audit
|
31
|
+
if @skip_audit
|
32
|
+
@skip_audit = false
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
31
36
|
data = {"changes" => changes, "metadata" => audit_metadata}
|
32
37
|
Audit::Tracking.log.record(audit_bucket, self.id, data)
|
33
38
|
@audit_metadata = {}
|
@@ -48,5 +53,13 @@ module Audit::Tracking
|
|
48
53
|
def audit_metadata(metadata={})
|
49
54
|
@audit_metadata = @audit_metadata.try(:update, metadata) || metadata
|
50
55
|
end
|
56
|
+
|
57
|
+
# Public: skip writing audit meatadata for the next write.
|
58
|
+
#
|
59
|
+
# Returns: nothing
|
60
|
+
def skip_audit
|
61
|
+
@skip_audit = true
|
62
|
+
nil
|
63
|
+
end
|
51
64
|
|
52
65
|
end
|
data/test/tracking_test.rb
CHANGED
@@ -20,13 +20,9 @@ class TrackingTest < Test::Unit::TestCase
|
|
20
20
|
super
|
21
21
|
@model = User.new
|
22
22
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
should "based on the model name" do
|
27
|
-
assert_equal :Users, @model.audit_bucket
|
28
|
-
end
|
29
|
-
|
23
|
+
|
24
|
+
should "generate an audit bucket name based on the model name" do
|
25
|
+
assert_equal :Users, @model.audit_bucket
|
30
26
|
end
|
31
27
|
|
32
28
|
should "track audit metadata for the next save" do
|
@@ -44,7 +40,7 @@ class TrackingTest < Test::Unit::TestCase
|
|
44
40
|
end
|
45
41
|
|
46
42
|
should "add audit-related methods" do
|
47
|
-
assert_equal %w{audit audit_bucket audit_metadata audits},
|
43
|
+
assert_equal %w{audit audit_bucket audit_metadata audits skip_audit},
|
48
44
|
@model.methods.map { |s| s.to_s }.grep(/audit/).sort
|
49
45
|
end
|
50
46
|
|
@@ -58,5 +54,14 @@ class TrackingTest < Test::Unit::TestCase
|
|
58
54
|
|
59
55
|
Audit::Tracking.log = Audit::Log
|
60
56
|
end
|
57
|
+
|
58
|
+
should "disable audits for the next write" do
|
59
|
+
user = User.create(:username => "adam", :age => 31)
|
60
|
+
user.skip_audit
|
61
|
+
|
62
|
+
user.save!
|
63
|
+
|
64
|
+
assert_equal 0, user.audits.length
|
65
|
+
end
|
61
66
|
|
62
67
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Adam Keys
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-05 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|