Permalink
Browse files

Merge pull request #1443 from padrino/dont_override_session_id_admin_…

…if_set

Don't step over :session_id setting on admin apps
  • Loading branch information...
ujifgc committed Oct 13, 2013
2 parents 66a66c7 + 6228bcc commit 8a8cb191b0eb2dcb3a4650d7b2297eaf5b89275e
Showing with 21 additions and 1 deletion.
  1. +1 −1 padrino-admin/lib/padrino-admin/access_control.rb
  2. +20 −0 padrino-admin/test/test_admin_application.rb
@@ -13,7 +13,7 @@ class << self
# Method used by Padrino::Application when we register the extension.
#
def registered(app)
- app.set :session_id, "_padrino_#{File.basename(Padrino.root)}_#{app.app_name}".to_sym
+ app.set :session_id, "_padrino_#{File.basename(Padrino.root)}_#{app.app_name}".to_sym unless app.respond_to?(:session_id)
app.set :admin_model, 'Account' unless app.respond_to?(:admin_model)
app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
app.helpers Padrino::Admin::Helpers::ViewHelpers
@@ -6,6 +6,26 @@ def setup
load_fixture 'data_mapper'
end
+ describe "session id setting" do
+ it "should provide it if it doesn't exist" do
+ mock_app do
+ register Padrino::Admin::AccessControl
+ end
+
+ assert_equal @app.session_id, "_padrino_#{File.basename(Padrino.root)}_#{@app.app_name}".to_sym
+ end
+
+ # it "should preserve it if it already existed" do
+ # Padrino.configure_apps { enable :sessions; set :session_id, "foo" }
+
+ # mock_app do
+ # register Padrino::Admin::AccessControl
+ # end
+
+ # assert_equal @app.session_id, "foo"
+ # end
+ end
+
it 'should require correctly login' do
mock_app do
register Padrino::Admin::AccessControl

0 comments on commit 8a8cb19

Please sign in to comment.