auditor 2.0.2 → 2.0.3

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.
@@ -44,13 +44,13 @@ module Auditor
44
44
  end
45
45
 
46
46
  def audit_as(user)
47
- previous_user = Audit::User.current_user
47
+ previous_user = Auditor::User.current_user
48
48
 
49
49
  begin
50
- Audit::User.current_user = user
50
+ Auditor::User.current_user = user
51
51
  result = yield if block_given?
52
52
  ensure
53
- Audit::User.current_user = previous_user
53
+ Auditor::User.current_user = previous_user
54
54
  end
55
55
 
56
56
  result
@@ -1,3 +1,3 @@
1
1
  module Auditor
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
@@ -15,4 +15,30 @@ describe Auditor::Status do
15
15
  obj.should_not be_auditing_enabled
16
16
  obj.should be_auditing_disabled
17
17
  end
18
+
19
+ it "should allow auditing as a specified user for a block of code" do
20
+ obj = Class.new { include Auditor::Status }.new
21
+ user1 = "user1"
22
+ user2 = "user2"
23
+ Auditor::User.current_user = user1
24
+
25
+ obj.audit_as(user2) { Auditor::User.current_user.should == user2 }
26
+ Auditor::User.current_user.should == user1
27
+ end
28
+
29
+ it "should allow a block of code to be executed with auditing disabled" do
30
+ obj = Class.new { include Auditor::Status }.new
31
+ obj.enable_auditing
32
+ obj.should be_auditing_enabled
33
+ obj.without_auditing { obj.should be_auditing_disabled }
34
+ obj.should be_auditing_enabled
35
+ end
36
+
37
+ it "should allow a block of code to be executed with auditing enabled" do
38
+ obj = Class.new { include Auditor::Status }.new
39
+ obj.disable_auditing
40
+ obj.should be_auditing_disabled
41
+ obj.with_auditing { obj.should be_auditing_enabled }
42
+ obj.should be_auditing_disabled
43
+ end
18
44
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auditor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 2
10
- version: 2.0.2
9
+ - 3
10
+ version: 2.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Kunkle
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-22 00:00:00 -04:00
18
+ date: 2011-03-23 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency