audit 0.2.0 → 0.3.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 +1 -1
- data/lib/audit.rb +1 -1
- data/lib/audit/tracking.rb +19 -6
- data/test/tracking_test.rb +6 -5
- metadata +2 -2
data/audit.gemspec
CHANGED
@@ -13,7 +13,7 @@ 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.
|
16
|
+
s.version = '0.3.0'
|
17
17
|
s.date = '2010-10-05'
|
18
18
|
s.rubyforge_project = 'audit'
|
19
19
|
|
data/lib/audit.rb
CHANGED
data/lib/audit/tracking.rb
CHANGED
@@ -28,8 +28,8 @@ module Audit::Tracking
|
|
28
28
|
#
|
29
29
|
# Returns nothing.
|
30
30
|
def audit
|
31
|
-
if
|
32
|
-
|
31
|
+
if skip_audit?
|
32
|
+
clear_skip
|
33
33
|
return
|
34
34
|
end
|
35
35
|
|
@@ -54,12 +54,25 @@ module Audit::Tracking
|
|
54
54
|
@audit_metadata = @audit_metadata.try(:update, metadata) || metadata
|
55
55
|
end
|
56
56
|
|
57
|
-
# Public:
|
57
|
+
# Public: Skip writing audit meatadata for the next write.
|
58
58
|
#
|
59
|
-
# Returns: nothing
|
59
|
+
# Returns: nothing.
|
60
60
|
def skip_audit
|
61
|
-
@
|
62
|
-
|
61
|
+
@skip = true
|
62
|
+
end
|
63
|
+
|
64
|
+
# Public: Write audit metadata for the next write.
|
65
|
+
#
|
66
|
+
# Returns: nothing.
|
67
|
+
def clear_skip
|
68
|
+
@skip = false
|
69
|
+
end
|
70
|
+
|
71
|
+
# Public: Flag indicating whether metadata is logged on the next write.
|
72
|
+
#
|
73
|
+
# Returns: nothing.
|
74
|
+
def skip_audit?
|
75
|
+
@skip ||= false
|
63
76
|
end
|
64
77
|
|
65
78
|
end
|
data/test/tracking_test.rb
CHANGED
@@ -39,7 +39,7 @@ class TrackingTest < Test::Unit::TestCase
|
|
39
39
|
assert_equal({}, user.audit_metadata) # Should clear audit after write
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
should_eventually "add audit-related methods" do
|
43
43
|
assert_equal %w{audit audit_bucket audit_metadata audits skip_audit},
|
44
44
|
@model.methods.map { |s| s.to_s }.grep(/audit/).sort
|
45
45
|
end
|
@@ -55,13 +55,14 @@ class TrackingTest < Test::Unit::TestCase
|
|
55
55
|
Audit::Tracking.log = Audit::Log
|
56
56
|
end
|
57
57
|
|
58
|
-
should "disable audits for the
|
58
|
+
should "disable audits for the one write" do
|
59
59
|
user = User.create(:username => "adam", :age => 31)
|
60
|
-
user.skip_audit
|
61
|
-
|
62
60
|
user.save!
|
63
61
|
|
64
|
-
|
62
|
+
user.skip_audit
|
63
|
+
user.update_attributes(:age => 32)
|
64
|
+
assert_equal 1, user.audits.length
|
65
|
+
assert !user.skip_audit?
|
65
66
|
end
|
66
67
|
|
67
68
|
end
|