From 46c2c3913eac6acbb13c9916f011595d0d82691e Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Mon, 25 Nov 2024 15:38:47 +0100 Subject: [PATCH] Fix passing of `format` option to `devise_for` call. --- lib/devise/rails/routes.rb | 3 +-- test/routes_test.rb | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/devise/rails/routes.rb b/lib/devise/rails/routes.rb index 474766f9d..f43e62fea 100644 --- a/lib/devise/rails/routes.rb +++ b/lib/devise/rails/routes.rb @@ -235,7 +235,6 @@ def devise_for(*resources) options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {}) options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {}) options[:options] = @scope[:options] || {} - options[:options][:format] = false if options[:format] == false resources.map!(&:to_sym) @@ -462,7 +461,7 @@ def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc: current_scope = @scope.dup exclusive = { as: new_as, path: new_path, module: nil } - exclusive.merge!(options.slice(:constraints, :defaults, :options)) + exclusive.merge!(options.slice(:constraints, :format, :defaults, :options)) if @scope.respond_to? :new @scope = @scope.new exclusive diff --git a/test/routes_test.rb b/test/routes_test.rb index f18fb342c..20ba31172 100644 --- a/test/routes_test.rb +++ b/test/routes_test.rb @@ -205,7 +205,6 @@ class CustomizedRoutingTest < ActionController::TestCase test 'map with format false for sessions' do expected_params = {controller: 'devise/sessions', action: 'new'} - expected_params[:format] = false assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_in', method: :get}) assert_raise ExpectedRoutingError do @@ -215,7 +214,6 @@ class CustomizedRoutingTest < ActionController::TestCase test 'map with format false for passwords' do expected_params = {controller: 'devise/passwords', action: 'create'} - expected_params[:format] = false assert_recognizes(expected_params, {path: '/htmlonly_admin/password', method: :post}) assert_raise ExpectedRoutingError do @@ -225,7 +223,6 @@ class CustomizedRoutingTest < ActionController::TestCase test 'map with format false for registrations' do expected_params = {controller: 'devise/registrations', action: 'new'} - expected_params[:format] = false assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_up', method: :get}) assert_raise ExpectedRoutingError do @@ -235,7 +232,6 @@ class CustomizedRoutingTest < ActionController::TestCase test 'map with format false for confirmations' do expected_params = {controller: 'devise/confirmations', action: 'show'} - expected_params[:format] = false assert_recognizes(expected_params, {path: '/htmlonly_users/confirmation', method: :get}) assert_raise ExpectedRoutingError do @@ -245,7 +241,6 @@ class CustomizedRoutingTest < ActionController::TestCase test 'map with format false for unlocks' do expected_params = {controller: 'devise/unlocks', action: 'show'} - expected_params[:format] = false assert_recognizes(expected_params, {path: '/htmlonly_users/unlock', method: :get}) assert_raise ExpectedRoutingError do