lockdown 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ module Lockdown
24
24
 
25
25
  # @return the version string for the library.
26
26
  def version
27
- '2.0.6'
27
+ '2.0.7'
28
28
  end
29
29
 
30
30
  def rails_mixin
@@ -170,7 +170,7 @@ module Lockdown
170
170
  # @return [Regex]
171
171
  def access_rights_for_user(user)
172
172
  return unless user
173
- return Lockdown::Resource.regex if administrator?(user)
173
+ return Lockdown::Resource.all_access if administrator?(user)
174
174
 
175
175
  user_groups = user.send(Lockdown.user_groups_hbtm_reference)
176
176
 
@@ -3,7 +3,7 @@
3
3
  module Lockdown
4
4
  class Resource
5
5
  class << self
6
- attr_accessor :resources, :resources_regex
6
+ attr_reader :resources
7
7
 
8
8
  # When a new resource is created, this method is called to register the root
9
9
  def register_regex(resource)
@@ -11,9 +11,14 @@ module Lockdown
11
11
  @resources << resource unless @resources.include?(resource)
12
12
  end
13
13
 
14
- # @return [Regexp] created from resources' base regex
15
- def regex
16
- @resources_regex ||= Lockdown.regex(@resources.join("|"))
14
+ # @return [String] all registered regular expressions joined by a pipe
15
+ def all_access
16
+ @resources.join(Lockdown::DELIMITER)
17
+ end
18
+
19
+ # Reset resources to empty array
20
+ def reset_resources
21
+ @resources = []
17
22
  end
18
23
  end # class block
19
24
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lockdown}
8
- s.version = "2.0.6"
8
+ s.version = "2.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew Stone"]
12
- s.date = %q{2010-11-20}
12
+ s.date = %q{2011-03-05}
13
13
  s.description = %q{Restrict access to your controller actions. }
14
14
  s.email = %q{andy@stonean.com}
15
15
  s.extra_rdoc_files = [
@@ -43,5 +43,13 @@ class TestLockdownResource < MiniTest::Unit::TestCase
43
43
  assert_equal resource.regex_pattern, "\/users(\/.*)?"
44
44
  end
45
45
 
46
+ def test_all_access
47
+ Lockdown::Resource.reset_resources
48
+ Lockdown::Resource.new(:users)
49
+ Lockdown::Resource.new(:posts)
50
+
51
+ assert_equal Lockdown::Resource.all_access, "(\/users(\/.*)?)#{Lockdown::DELIMITER}(\/posts(\/.*)?)"
52
+ end
53
+
46
54
  end
47
55
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 0
8
- - 6
9
- version: 2.0.6
8
+ - 7
9
+ version: 2.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Stone
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-20 00:00:00 -05:00
17
+ date: 2011-03-05 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20