audit 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.2.0'
16
+ s.version = '0.3.0'
17
17
  s.date = '2010-10-05'
18
18
  s.rubyforge_project = 'audit'
19
19
 
@@ -3,7 +3,7 @@
3
3
  module Audit
4
4
 
5
5
  # Everything needs a version.
6
- VERSION = '0.2.0'
6
+ VERSION = '0.3.0'
7
7
 
8
8
  autoload :Log, "audit/log"
9
9
  autoload :Changeset, "audit/changeset"
@@ -28,8 +28,8 @@ module Audit::Tracking
28
28
  #
29
29
  # Returns nothing.
30
30
  def audit
31
- if @skip_audit
32
- @skip_audit = false
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: skip writing audit meatadata for the next write.
57
+ # Public: Skip writing audit meatadata for the next write.
58
58
  #
59
- # Returns: nothing
59
+ # Returns: nothing.
60
60
  def skip_audit
61
- @skip_audit = true
62
- nil
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
@@ -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
- should "add audit-related methods" do
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 next write" do
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
- assert_equal 0, user.audits.length
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
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Keys