lockdown 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,4 +4,3 @@ pkg/**
4
4
  doc/**
5
5
  email.txt
6
6
  coverage/**
7
- lockdown.gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.6.1
@@ -6,4 +6,6 @@ module Lockdown
6
6
  class PermissionScopeCollision < StandardError; end
7
7
 
8
8
  class InvalidPermissionAssignment < StandardError; end
9
+
10
+ class GroupUndefinedError < StandardError; end
9
11
  end
@@ -1,5 +1,9 @@
1
1
  module Lockdown
2
2
  module RspecHelper
3
+ def self.included(mod)
4
+ Lockdown.maybe_parse_init
5
+ end
6
+
3
7
  def login_admin
4
8
  login_user(:admin)
5
9
  end
@@ -53,6 +57,7 @@ module Lockdown
53
57
  methods = controller.send :action_methods
54
58
 
55
59
  if excepts = hash.delete(:except)
60
+ excepts = Array.new(excepts)
56
61
  methods.reject!{|m| excepts.include?(m.to_sym)}
57
62
  end
58
63
 
@@ -86,11 +91,12 @@ module Lockdown
86
91
 
87
92
  # You may want to override this method
88
93
  def mock_user
89
- mock :user,
90
- :first_name => 'John',
91
- :last_name => 'Smith',
92
- :password => "mysecret",
93
- :password_confirmation => "mysecret"
94
+ mock_model User,
95
+ :user_groups => [],
96
+ :first_name => 'John',
97
+ :last_name => 'Smith',
98
+ :password => "mysecret",
99
+ :password_confirmation => "mysecret"
94
100
  end
95
101
 
96
102
  def create_user_session
@@ -256,7 +256,11 @@ module Lockdown
256
256
  if has_user_group?(sym)
257
257
  permissions = user_groups[sym] || []
258
258
  else
259
- permissions = ug.permissions
259
+ if ug.respond_to?(:permissions)
260
+ permissions = ug.permissions
261
+ else
262
+ raise GroupUndefinedError, "#{ug} not found in init.rb and does not respond to #permissions"
263
+ end
260
264
  end
261
265
 
262
266
 
@@ -8,7 +8,6 @@ class TestAController
8
8
  end
9
9
 
10
10
  class RspecEnv
11
- include Lockdown::RspecHelper
12
11
  end
13
12
 
14
13
  describe Lockdown::RspecHelper do
@@ -24,6 +23,8 @@ describe Lockdown::RspecHelper do
24
23
 
25
24
  usr_group = mock :usr_group
26
25
 
26
+ Lockdown.should_receive(:maybe_parse_init)
27
+ RspecEnv.send :include, Lockdown::RspecHelper
27
28
  @rspec_env = RspecEnv.new
28
29
  @rspec_env.stub!(:controller).and_return(@controller)
29
30
  @rspec_env.stub!(:mock_user).and_return(usr)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-13 00:00:00 -05:00
12
+ date: 2009-11-27 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency