Allow default scope to beconfigured.
This commit is contained in:
parent
8d5445579c
commit
1a8dc7fe37
|
@ -1,7 +1,11 @@
|
||||||
|
* deprecations
|
||||||
|
* Deprecate :singular in devise_for and use :scope instead
|
||||||
|
|
||||||
* enhancements
|
* enhancements
|
||||||
* [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
|
* [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
|
||||||
overwriten in ApplicationController
|
overwriten in ApplicationController
|
||||||
* Create sign_in_and_redirect and sign_out_and_redirect helpers
|
* Create sign_in_and_redirect and sign_out_and_redirect helpers
|
||||||
|
* Warden::Manager.default_scope is automatically configured to the first given scope
|
||||||
|
|
||||||
== 0.5.3
|
== 0.5.3
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,9 @@ rescue
|
||||||
require 'warden'
|
require 'warden'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Set the default_scope to nil, so it's overwritten when the first route is declared.
|
||||||
|
Warden::Manager.default_scope = nil
|
||||||
|
|
||||||
require 'devise/strategies/base'
|
require 'devise/strategies/base'
|
||||||
require 'devise/serializers/base'
|
require 'devise/serializers/base'
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ module ActionController::Routing
|
||||||
resources.map!(&:to_sym)
|
resources.map!(&:to_sym)
|
||||||
resources.each do |resource|
|
resources.each do |resource|
|
||||||
mapping = Devise::Mapping.new(resource, options.dup)
|
mapping = Devise::Mapping.new(resource, options.dup)
|
||||||
|
Warden::Manager.default_scope ||= mapping.name
|
||||||
Devise.mappings[mapping.name] = mapping
|
Devise.mappings[mapping.name] = mapping
|
||||||
|
|
||||||
route_options = mapping.route_options.merge(:path_prefix => mapping.raw_path, :name_prefix => "#{mapping.name}_")
|
route_options = mapping.route_options.merge(:path_prefix => mapping.raw_path, :name_prefix => "#{mapping.name}_")
|
||||||
|
|
|
@ -66,6 +66,10 @@ class DeviseTest < ActiveSupport::TestCase
|
||||||
assert manager.silence_missing_strategies
|
assert manager.silence_missing_strategies
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'warden default scope is set' do
|
||||||
|
assert_equal :user, Warden::Manager.default_scope
|
||||||
|
end
|
||||||
|
|
||||||
test 'warden manager user configuration through a block' do
|
test 'warden manager user configuration through a block' do
|
||||||
begin
|
begin
|
||||||
@executed = false
|
@executed = false
|
||||||
|
|
|
@ -4,7 +4,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.devise_for :account, :path_names => {
|
map.devise_for :account, :path_names => {
|
||||||
:sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification'
|
:sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification'
|
||||||
}
|
}
|
||||||
map.devise_for :organizers, :singular => 'manager',
|
map.devise_for :organizers, :scope => 'manager',
|
||||||
:path_prefix => '/:locale',
|
:path_prefix => '/:locale',
|
||||||
:requirements => { :extra => 'value' }
|
:requirements => { :extra => 'value' }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue