mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:58:06 -05:00
Compare commits
7 Commits
password-l
...
v1.5.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59cd9e72b9 | ||
|
|
fbb5c2af5c | ||
|
|
e137e9d5d1 | ||
|
|
5bc96f294f | ||
|
|
cd8af3c00c | ||
|
|
f5c643946b | ||
|
|
86d4ec223d |
@@ -1,3 +1,10 @@
|
||||
== 1.5.3
|
||||
|
||||
* bug fix
|
||||
* Ensure delegator converts scope to symbol (by github.com/dmitriy-kiriyenko)
|
||||
* Ensure passing :format => false to devise_for is not permanent
|
||||
* Ensure path checker does not check invalid routes
|
||||
|
||||
== 1.5.2
|
||||
|
||||
* enhancements
|
||||
|
||||
@@ -8,9 +8,9 @@ module Devise
|
||||
def failure_app(env)
|
||||
app = env["warden.options"] &&
|
||||
(scope = env["warden.options"][:scope]) &&
|
||||
Devise.mappings[scope].failure_app
|
||||
Devise.mappings[scope.to_sym].failure_app
|
||||
|
||||
app || Devise::FailureApp
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,8 +23,7 @@ module Devise
|
||||
#
|
||||
class Mapping #:nodoc:
|
||||
attr_reader :singular, :scoped_path, :path, :controllers, :path_names,
|
||||
:class_name, :sign_out_via, :format, :used_routes, :used_helpers,
|
||||
:constraints, :defaults, :failure_app
|
||||
:class_name, :sign_out_via, :format, :used_routes, :used_helpers, :failure_app
|
||||
|
||||
alias :name :singular
|
||||
|
||||
@@ -64,8 +63,6 @@ module Devise
|
||||
default_failure_app(options)
|
||||
default_controllers(options)
|
||||
default_path_names(options)
|
||||
default_constraints(options)
|
||||
default_defaults(options)
|
||||
default_used_route(options)
|
||||
default_used_helpers(options)
|
||||
end
|
||||
|
||||
@@ -12,7 +12,8 @@ module Devise
|
||||
end
|
||||
|
||||
def signing_out?
|
||||
@current_path == send("destroy_#{@scope}_session_path")
|
||||
route = "destroy_#{@scope}_session_path"
|
||||
respond_to?(route) && @current_path == send(route)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -185,7 +185,7 @@ module ActionDispatch::Routing
|
||||
options[:path_names] = (@scope[:path_names] || {}).merge(options[:path_names] || {})
|
||||
options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
|
||||
options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
|
||||
@scope[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
|
||||
options[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
|
||||
|
||||
resources.map!(&:to_sym)
|
||||
|
||||
@@ -208,7 +208,7 @@ module ActionDispatch::Routing
|
||||
|
||||
devise_scope mapping.name do
|
||||
yield if block_given?
|
||||
with_devise_exclusive_scope mapping.fullpath, mapping.name, mapping.constraints, mapping.defaults do
|
||||
with_devise_exclusive_scope mapping.fullpath, mapping.name, options do
|
||||
routes.each { |mod| send("devise_#{mod}", mapping, mapping.controllers) }
|
||||
end
|
||||
end
|
||||
@@ -368,12 +368,15 @@ module ActionDispatch::Routing
|
||||
@scope[:path] = path
|
||||
end
|
||||
|
||||
def with_devise_exclusive_scope(new_path, new_as, new_constraints, new_defaults) #:nodoc:
|
||||
old_as, old_path, old_module, old_constraints, old_defaults = @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults]
|
||||
@scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults] = new_as, new_path, nil, new_constraints, new_defaults
|
||||
def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
|
||||
old_as, old_path, old_module, old_constraints, old_defaults, old_options =
|
||||
*@scope.values_at(:as, :path, :module, :constraints, :defaults, :options)
|
||||
@scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults], @scope[:options] =
|
||||
new_as, new_path, nil, *options.values_at(:constraints, :defaults, :options)
|
||||
yield
|
||||
ensure
|
||||
@scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults] = old_as, old_path, old_module, old_constraints, old_defaults
|
||||
@scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults], @scope[:options] =
|
||||
old_as, old_path, old_module, old_constraints, old_defaults, old_options
|
||||
end
|
||||
|
||||
def raise_no_devise_method_error!(klass) #:nodoc:
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Devise
|
||||
VERSION = "1.5.2".freeze
|
||||
VERSION = "1.5.3".freeze
|
||||
end
|
||||
|
||||
19
test/delegator_test.rb
Normal file
19
test/delegator_test.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DelegatorTest < ActiveSupport::TestCase
|
||||
def delegator
|
||||
Devise::Delegator.new
|
||||
end
|
||||
|
||||
test 'failure_app returns default failure app if no warden options in env' do
|
||||
assert_equal Devise::FailureApp, delegator.failure_app({})
|
||||
end
|
||||
|
||||
test 'failure_app returns default failure app if no scope in warden options' do
|
||||
assert_equal Devise::FailureApp, delegator.failure_app({"warden.options" => {}})
|
||||
end
|
||||
|
||||
test 'failure_app returns associated failure app by scope in the given environment' do
|
||||
assert_kind_of Proc, delegator.failure_app({"warden.options" => {:scope => "manager"}})
|
||||
end
|
||||
end
|
||||
21
test/path_checker_test.rb
Normal file
21
test/path_checker_test.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PathCheckerTest < ActiveSupport::TestCase
|
||||
test 'check if sign out path matches' do
|
||||
path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_out"}, :user)
|
||||
assert path_checker.signing_out?
|
||||
|
||||
path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_in"}, :user)
|
||||
assert_not path_checker.signing_out?
|
||||
end
|
||||
|
||||
test 'considers script name' do
|
||||
path_checker = Devise::PathChecker.new({"SCRIPT_NAME" => "/users", "PATH_INFO" => "/sign_out"}, :user)
|
||||
assert path_checker.signing_out?
|
||||
end
|
||||
|
||||
test 'ignores invalid routes' do
|
||||
path_checker = Devise::PathChecker.new({"PATH_INFO" => "/users/sign_in"}, :omg)
|
||||
assert_not path_checker.signing_out?
|
||||
end
|
||||
end
|
||||
@@ -225,6 +225,10 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock.xml', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with format false is not permanent' do
|
||||
assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
|
||||
end
|
||||
end
|
||||
|
||||
class ScopedRoutingTest < ActionController::TestCase
|
||||
|
||||
Reference in New Issue
Block a user