credentials 2.2.0 → 2.2.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.2.1
data/credentials.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{credentials}
8
- s.version = "2.2.0"
8
+ s.version = "2.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Powell"]
@@ -1,99 +1,101 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- class TestController < ActionController::Base
4
- self.current_user_method = :logged_in_user
5
- requires_permission_to :view, :stuff, :except => [ :public ]
6
- requires_permission_to :break, :stuff, :only => [ :dangerous ]
3
+ if defined?(ActionController)
4
+ class TestController < ActionController::Base
5
+ self.current_user_method = :logged_in_user
6
+ requires_permission_to :view, :stuff, :except => [ :public ]
7
+ requires_permission_to :break, :stuff, :only => [ :dangerous ]
7
8
 
8
- def index; end
9
- def public; end
10
- def dangerous; end
9
+ def index; end
10
+ def public; end
11
+ def dangerous; end
11
12
 
12
- def rescue_action(e)
13
- raise e
13
+ def rescue_action(e)
14
+ raise e
15
+ end
14
16
  end
15
- end
16
17
 
17
- class TestUser
18
- credentials do |user|
19
- user.can :view, :stuff
20
- user.can :break, :stuff, :if => :special?
18
+ class TestUser
19
+ credentials do |user|
20
+ user.can :view, :stuff
21
+ user.can :break, :stuff, :if => :special?
22
+ end
21
23
  end
22
- end
23
24
 
24
- describe TestController do
25
- it "should know how to specify access credentials" do
26
- controller.class.should respond_to :requires_permission_to
27
- end
28
-
29
- it "should use the right method to look up the current user" do
30
- controller.class.current_user_method.should == :logged_in_user
31
- end
32
-
33
- it "should check credentials on each request" do
34
- controller.should_receive(:check_credentials)
35
- get :index
36
- end
25
+ describe TestController do
26
+ it "should know how to specify access credentials" do
27
+ controller.class.should respond_to(:requires_permission_to)
28
+ end
37
29
 
38
- describe "when logged in" do
39
- before :each do
40
- @user = TestUser.new
41
- controller.should_receive(:logged_in_user).and_return(@user)
30
+ it "should use the right method to look up the current user" do
31
+ controller.class.current_user_method.should == :logged_in_user
42
32
  end
43
-
44
- it "should display stuff" do
45
- lambda {
46
- get :index
47
- response.should be_success
48
- }.should_not raise_error(Credentials::Errors::NotLoggedInError)
33
+
34
+ it "should check credentials on each request" do
35
+ controller.should_receive(:check_credentials)
36
+ get :index
49
37
  end
50
-
51
- describe "as someone with permission to break stuff" do
52
- before(:each) do
53
- @user.stub!(:special?).and_return(true)
54
- @user.should be_able_to(:view, :stuff)
55
- @user.should be_able_to(:break, :stuff)
38
+
39
+ describe "when logged in" do
40
+ before :each do
41
+ @user = TestUser.new
42
+ controller.should_receive(:logged_in_user).and_return(@user)
56
43
  end
57
-
58
- it "should have access to dangerous actions" do
44
+
45
+ it "should display stuff" do
59
46
  lambda {
60
- get :dangerous
47
+ get :index
61
48
  response.should be_success
62
- }.should_not raise_error(Credentials::Errors::AccessDeniedError)
49
+ }.should_not raise_error(Credentials::Errors::NotLoggedInError)
63
50
  end
64
- end
65
51
 
66
- describe "as someone without permission to break stuff" do
67
- before(:each) do
68
- @user.stub!(:special?).and_return(false)
69
- @user.should_not be_able_to(:break, :stuff)
52
+ describe "as someone with permission to break stuff" do
53
+ before(:each) do
54
+ @user.stub!(:special?).and_return(true)
55
+ @user.should be_able_to(:view, :stuff)
56
+ @user.should be_able_to(:break, :stuff)
57
+ end
58
+
59
+ it "should have access to dangerous actions" do
60
+ lambda {
61
+ get :dangerous
62
+ response.should be_success
63
+ }.should_not raise_error(Credentials::Errors::AccessDeniedError)
64
+ end
70
65
  end
66
+
67
+ describe "as someone without permission to break stuff" do
68
+ before(:each) do
69
+ @user.stub!(:special?).and_return(false)
70
+ @user.should_not be_able_to(:break, :stuff)
71
+ end
71
72
 
72
- it "should not have access to dangerous actions" do
73
- lambda {
74
- get :dangerous
75
- response.should_not be_success
76
- }.should raise_error(Credentials::Errors::AccessDeniedError)
73
+ it "should not have access to dangerous actions" do
74
+ lambda {
75
+ get :dangerous
76
+ response.should_not be_success
77
+ }.should raise_error(Credentials::Errors::AccessDeniedError)
78
+ end
77
79
  end
78
80
  end
79
- end
80
81
 
81
- describe "when not logged in" do
82
- before :each do
83
- controller.should_receive(:logged_in_user).and_return(nil)
84
- end
82
+ describe "when not logged in" do
83
+ before :each do
84
+ controller.should_receive(:logged_in_user).and_return(nil)
85
+ end
85
86
 
86
- it "should not have access to stuff" do
87
- lambda {
88
- get :index
89
- }.should raise_error(Credentials::Errors::NotLoggedInError)
90
- end
87
+ it "should not have access to stuff" do
88
+ lambda {
89
+ get :index
90
+ }.should raise_error(Credentials::Errors::NotLoggedInError)
91
+ end
91
92
 
92
- it "should have access to public stuff" do
93
- lambda {
94
- get :public
95
- response.should be_success
96
- }.should_not raise_error(Credentials::Errors::AccessDeniedError)
93
+ it "should have access to public stuff" do
94
+ lambda {
95
+ get :public
96
+ response.should be_success
97
+ }.should_not raise_error(Credentials::Errors::AccessDeniedError)
98
+ end
97
99
  end
98
100
  end
99
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Powell