Skip to content

Commit

Permalink
[padrino-admin] don't enable sessions in register, generate in admin/…
Browse files Browse the repository at this point in the history
…app.rb instead
  • Loading branch information
achiurizo committed May 21, 2011
1 parent abd3715 commit fd66302
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 1 addition & 2 deletions padrino-admin/lib/padrino-admin/access_control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module AccessControl
class << self
def registered(app)
app.set :session_id, "_padrino_#{File.basename(Padrino.root)}_#{app.app_name}".to_sym
app.enable :sessions
app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
app.helpers Padrino::Admin::Helpers::ViewHelpers
app.before { login_required }
Expand Down Expand Up @@ -147,4 +146,4 @@ def path(prefix=nil)
end # ProjectModule
end # AccessControl
end # Admin
end # Padrino
end # Padrino
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class Admin < Padrino::Application
# disable :flash # Disables rack-flash (enabled by default if Rack::Flash is defined)
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
#

set :login_page, "/admin/sessions/new"

enable :sessions
disable :store_location

access_control.roles_for :any do |role|
Expand All @@ -28,4 +31,4 @@ class Admin < Padrino::Application

access_control.roles_for :admin do |role|
end
end
end
7 changes: 6 additions & 1 deletion padrino-admin/test/test_admin_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def setup
should 'require correctly login' do
mock_app do
register Padrino::Admin::AccessControl
enable :sessions

# Do a simple mapping
access_control.roles_for :any do |role|
Expand Down Expand Up @@ -37,6 +38,7 @@ def setup
set :app_name, :basic_app
register Padrino::Admin::AccessControl
enable :store_location
enable :sessions
set :login_page, "/login"

access_control.roles_for :any do |role|
Expand Down Expand Up @@ -70,6 +72,7 @@ def setup
should 'set advanced roles with store location and login page' do
mock_app do
register Padrino::Admin::AccessControl
enable :sessions

access_control.roles_for :any do |role|
role.protect "/"
Expand Down Expand Up @@ -146,6 +149,7 @@ def setup
should 'emulate an ecommerce app' do
mock_app do
register Padrino::Admin::AccessControl
enable :sessions

access_control.roles_for :any do |role|
role.protect "/cart"
Expand Down Expand Up @@ -196,6 +200,7 @@ def setup
should 'check access control helper' do
mock_app do
register Padrino::Admin::AccessControl
enable :sessions

access_control.roles_for :any do |role|
role.project_module :foo, "/foo"
Expand Down Expand Up @@ -243,4 +248,4 @@ def setup
get "/modules"
assert_equal "admin => /admin", body
end
end
end

0 comments on commit fd66302

Please sign in to comment.