New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding run_callbacks option to user. #42

Merged
merged 3 commits into from Feb 15, 2012
Jump to file or symbol
Failed to load files and symbols.
+8 −4
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Added documentation and setting the default scope when scope is nil

  • Loading branch information...
Rodrigo Flores
Rodrigo Flores committed Feb 15, 2012
commit b61a8af870de10595e90ff9723e0ffdd02d34eb9
View
@@ -144,7 +144,7 @@ def unauthenticated?(scope = @config.default_scope)
#
# Parameters:
# user - An object that has been setup to serialize into and out of the session.
# opts - An options hash. Use the :scope option to set the scope of the user, set the :store option to false to skip serializing into the session.
# opts - An options hash. Use the :scope option to set the scope of the user, set the :store option to false to skip serializing into the session, set the :run_callbacks to false to skip running the callbacks (the default is true).
#
# :api: public
def set_user(user, opts = {})
@@ -178,8 +178,12 @@ def set_user(user, opts = {})
# # with scope
# env['warden'].user(:admin)
#
# # with default scope and run_callbacks option
# env['warden'].user(nil, :run_callbacks => false)
# :api: public
def user(scope = @config.default_scope, opts = {})
scope ||= @config.default_scope
@users[scope] ||= begin
user = session_serializer.fetch(scope)
@@ -444,7 +444,7 @@
it "should not call run_callbacks when we pass a :run_callback => false" do
app = lambda do |env|
env['warden'].manager.should_not_receive(:_run_callbacks)
env['warden'].user(env['warden'].config.default_scope, :run_callbacks => false)
env['warden'].user(nil, :run_callbacks => false)
valid_response
end
setup_rack(app).call(@env)
@@ -453,7 +453,7 @@
it "should call run_callbacks when we pass a :run_callback => true" do
app = lambda do |env|
env['warden'].manager.should_receive(:_run_callbacks)
env['warden'].user(env['warden'].config.default_scope, :run_callbacks => true)
env['warden'].user(nil, :run_callbacks => true)
valid_response
end
setup_rack(app).call(@env)
@@ -956,4 +956,4 @@ def wrap_app(app, &blk)
session['warden.user.baz.key'].should == "User"
end
end
end
end
ProTip! Use n and p to navigate between commits in a pull request.