lockdown 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.1
1
+ 1.6.0
data/lib/lockdown.rb CHANGED
@@ -16,7 +16,7 @@ module Lockdown
16
16
  extend Lockdown::References
17
17
  extend Lockdown::Helper
18
18
 
19
- VERSION = '1.5.1'
19
+ VERSION = '1.6.0'
20
20
 
21
21
  class << self
22
22
  attr_accessor :logger
@@ -54,7 +54,7 @@ module Lockdown
54
54
 
55
55
  if File.exists?(Lockdown.init_file)
56
56
  Lockdown.logger.info "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
57
- require Lockdown.init_file
57
+ load Lockdown.init_file
58
58
  else
59
59
  Lockdown.logger.info "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
60
60
  end
@@ -66,14 +66,14 @@ module Lockdown
66
66
  # cache_classes is true in production and testing, need to
67
67
  # modify the ApplicationController
68
68
  def controller_parent
69
- if caching_classes?
69
+ if caching?
70
70
  ApplicationController
71
71
  else
72
72
  ActionController::Base
73
73
  end
74
74
  end
75
75
 
76
- def caching_classes?
76
+ def caching?
77
77
  ::Rails.configuration.cache_classes
78
78
  end
79
79
 
@@ -63,6 +63,9 @@ module Lockdown
63
63
  end
64
64
 
65
65
  def authorized?(url, method = nil)
66
+ # Reset access unless caching?
67
+ add_lockdown_session_values unless Lockdown.caching?
68
+
66
69
  return false unless url
67
70
 
68
71
  return true if current_user_is_admin?
@@ -9,6 +9,8 @@ module Lockdown
9
9
  if user
10
10
  session[:access_rights] = Lockdown::System.access_rights_for_user(user)
11
11
  session[:current_user_id] = user.id
12
+ else
13
+ session[:access_rights] = Lockdown::System.public_access
12
14
  end
13
15
  end
14
16
 
@@ -13,7 +13,7 @@ module Lockdown
13
13
 
14
14
  Lockdown::Database.sync_with_db unless skip_sync?
15
15
 
16
- @initialized = true
16
+ @initialized = true if Lockdown.caching?
17
17
  end
18
18
 
19
19
  def self.initialized?
@@ -37,7 +37,8 @@ describe Lockdown::Frameworks::Rails::Controller::Lock do
37
37
  end
38
38
 
39
39
  describe "#configure_lockdown" do
40
- it "should call check_session_expiry and store_location" do
40
+ it "should call Lockdown.maybe_parse_init, check_session_expiry and store_location" do
41
+ Lockdown.should_receive(:maybe_parse_init)
41
42
  @controller.should_receive(:check_session_expiry)
42
43
  @controller.should_receive(:store_location)
43
44
 
@@ -115,6 +116,7 @@ describe Lockdown::Frameworks::Rails::Controller::Lock do
115
116
 
116
117
  request = mock("request")
117
118
  request.stub!(:method).and_return(:get)
119
+ Lockdown.stub(:caching?).and_return(true)
118
120
  @controller.stub!(:params).and_return({})
119
121
  @controller.stub!(:request).and_return(request)
120
122
 
@@ -127,6 +129,13 @@ describe Lockdown::Frameworks::Rails::Controller::Lock do
127
129
  URI.stub!(:split).with(@a_path).and_return(a_path_parts)
128
130
  end
129
131
 
132
+ it "should call add_lockdown_session_values unless caching" do
133
+ Lockdown.stub(:caching?).and_return(false)
134
+ @controller.should_receive(:add_lockdown_session_values)
135
+
136
+ @controller.send(:authorized?,nil)
137
+ end
138
+
130
139
  it "should return false if url is nil" do
131
140
  @controller.send(:authorized?,nil).should be_false
132
141
  end
@@ -115,12 +115,12 @@ describe Lockdown::Frameworks::Rails::Environment do
115
115
 
116
116
  describe "#controller_parent" do
117
117
  it "should return ActionController::Base if not caching classes" do
118
- @env.should_receive(:caching_classes?).and_return(false)
118
+ @env.should_receive(:caching?).and_return(false)
119
119
  @env.controller_parent.should == ActionController::Base
120
120
  end
121
121
 
122
122
  it "should return ApplicationController if caching classes" do
123
- @env.should_receive(:caching_classes?).and_return(true)
123
+ @env.should_receive(:caching?).and_return(true)
124
124
  @env.controller_parent.should == ApplicationController
125
125
  end
126
126
 
@@ -20,6 +20,8 @@ describe Lockdown::System do
20
20
 
21
21
  Lockdown::Database.should_receive :sync_with_db
22
22
 
23
+ Lockdown.should_receive :caching?
24
+
23
25
  Lockdown::System.configure do
24
26
  end
25
27
  end
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.5.1
4
+ version: 1.6.0
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-09 00:00:00 -05:00
12
+ date: 2009-11-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency