Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to work with Warden 0.8.0.

  • Loading branch information...
commit 543fe077d80c34633420d0f9581a56b52c6b630f 1 parent 7c67388
@josevalim josevalim authored
View
2  Rakefile
@@ -44,7 +44,7 @@ begin
s.description = "Flexible authentication solution for Rails with Warden"
s.authors = ['José Valim', 'Carlos Antônio']
s.files = FileList["[A-Z]*", "{app,config,generators,lib}/**/*", "init.rb"]
- s.add_dependency("warden", "~> 0.6.4")
+ s.add_dependency("warden", "~> 0.8.0")
end
Jeweler::GemcutterTasks.new
View
20 lib/devise.rb
@@ -103,6 +103,10 @@ module Orm
mattr_accessor :scoped_views
@@scoped_views = false
+ # The default scope which is used by warden
+ mattr_accessor :default_scope
+ @@default_scope = nil
+
class << self
# Default way to setup Devise. Run script/generate devise_install to create
# a fresh initializer with all configuration values.
@@ -138,15 +142,16 @@ def default_url_options(&block)
# A method used internally to setup warden manager from the Rails initialize
# block.
- def configure_warden_manager(manager) #:nodoc:
- manager.default_strategies *Devise::STRATEGIES
- manager.default_serializers *Devise::SERIALIZERS
- manager.failure_app = Devise::FailureApp
- manager.silence_missing_strategies!
- manager.silence_missing_serializers!
+ def configure_warden(config) #:nodoc:
+ config.default_strategies *Devise::STRATEGIES
+ config.default_serializers *Devise::SERIALIZERS
+ config.failure_app = Devise::FailureApp
+ config.silence_missing_strategies!
+ config.silence_missing_serializers!
+ config.default_scope = Devise.default_scope
# If the user provided a warden hook, call it now.
- @warden_config.try :call, manager
+ @warden_config.try :call, config
end
# The class of the configured ORM
@@ -171,6 +176,5 @@ def friendly_token
# Clear some Warden default configuration which will be overwritten
Warden::Strategies.clear!
Warden::Serializers.clear!
-Warden::Manager.default_scope = nil
require 'devise/rails'
View
4 lib/devise/rails.rb
@@ -6,8 +6,8 @@
# Adds Warden Manager to Rails middleware stack, configuring default devise
# strategy and also the failure app.
- Rails.configuration.middleware.use Warden::Manager do |manager|
- Devise.configure_warden_manager(manager)
+ Rails.configuration.middleware.use Warden::Manager do |config|
+ Devise.configure_warden(config)
end
I18n.load_path.unshift File.expand_path(File.join(File.dirname(__FILE__), 'locales', 'en.yml'))
View
2  lib/devise/rails/routes.rb
@@ -82,7 +82,7 @@ def devise_for(*resources)
resources.map!(&:to_sym)
resources.each do |resource|
mapping = Devise::Mapping.new(resource, options.dup)
- Warden::Manager.default_scope ||= mapping.name
+ Devise.default_scope ||= mapping.name
Devise.mappings[mapping.name] = mapping
route_options = mapping.route_options.merge(:path_prefix => mapping.raw_path, :name_prefix => "#{mapping.name}_")
View
6 lib/devise/test_helpers.rb
@@ -14,10 +14,10 @@ class TestWarden < Warden::Proxy #:nodoc:
def initialize(controller)
@controller = controller
- manager = Warden::Manager.new(nil) do |manager|
- Devise.configure_warden_manager(manager)
+ manager = Warden::Manager.new(nil) do |config|
+ Devise.configure_warden(config)
end
- super(controller.request.env, manager.config)
+ super(controller.request.env, manager)
end
def authenticate!(*args)
View
51 test/devise_test.rb
@@ -7,34 +7,6 @@ def self.clean_warden_config!
end
class DeviseTest < ActiveSupport::TestCase
- class MockManager
- attr_accessor :failure_app
- attr_reader :default_strategies, :silence_missing_strategies
-
- def silence_missing_strategies!
- @silence_missing_strategies = true
- end
-
- def silence_missing_serializers!
- @silence_missing_serializers = true
- end
-
- def default_strategies(*args)
- if args.empty?
- @default_strategies
- else
- @default_strategies = args
- end
- end
-
- def default_serializers(*args)
- if args.empty?
- @default_serializers
- else
- @default_serializers = args
- end
- end
- end
test 'DeviseMailer.sender can be configured through Devise' do
swap DeviseMailer, :sender => "foo@bar" do
@@ -58,28 +30,25 @@ def default_serializers(*args)
end
test 'warden manager configuration' do
- manager = MockManager.new
- Devise.configure_warden_manager(manager)
-
- assert_equal Devise::FailureApp, manager.failure_app
- assert_equal [:authenticatable], manager.default_strategies
- assert manager.silence_missing_strategies
- end
+ config = Warden::Config.new
+ Devise.configure_warden(config)
- test 'warden default scope is set' do
- assert_equal :user, Warden::Manager.default_scope
+ assert_equal Devise::FailureApp, config.failure_app
+ assert_equal [:authenticatable], config.default_strategies
+ assert_equal :user, config.default_scope
+ assert config.silence_missing_strategies?
+ assert config.silence_missing_serializers?
end
test 'warden manager user configuration through a block' do
begin
@executed = false
- Devise.warden do |manager|
+ Devise.warden do |config|
@executed = true
- assert_kind_of MockManager, manager
+ assert_kind_of Warden::Config, config
end
- manager = MockManager.new
- Devise.configure_warden_manager(manager)
+ Devise.configure_warden(Warden::Config.new)
assert @executed
ensure
Devise.clean_warden_config!
View
2  test/integration/trackable_test.rb
@@ -51,7 +51,7 @@ class TrackableHooksTest < ActionController::IntegrationTest
assert_equal 2, user.sign_in_count
end
- test "does not update anything if user is signed out along the way" do
+ test "does not update anything if user has signed out along the way" do
swap Devise, :confirm_within => 0 do
user = create_user(:confirm => false)
sign_in_as_user
Please sign in to comment.
Something went wrong with that request. Please try again.