diff --git a/lib/devise/mapping.rb b/lib/devise/mapping.rb index bef62234..0d030b46 100644 --- a/lib/devise/mapping.rb +++ b/lib/devise/mapping.rb @@ -78,6 +78,8 @@ module Devise if options.has_key?(:only) @used_routes = self.routes & Array(options[:only]).map(&singularizer) + elsif options[:skip] == :all + @used_routes = [] else @used_routes = self.routes - Array(options[:skip]).map(&singularizer) end diff --git a/test/mapping_test.rb b/test/mapping_test.rb index 2a60d57f..e9f50503 100644 --- a/test/mapping_test.rb +++ b/test/mapping_test.rb @@ -31,6 +31,10 @@ class MappingTest < ActiveSupport::TestCase assert_equal "admin_area", Devise.mappings[:admin].path end + test 'allows to skip all routes' do + assert_equal [], Devise.mappings[:skip_admin].used_routes + end + test 'sign_out_via defaults to :get' do assert_equal :get, Devise.mappings[:user].sign_out_via end diff --git a/test/rails_app/config/routes.rb b/test/rails_app/config/routes.rb index 602b14a8..296e9afe 100644 --- a/test/rails_app/config/routes.rb +++ b/test/rails_app/config/routes.rb @@ -50,6 +50,8 @@ Rails.application.routes.draw do constraints(:host => /192\.168\.1\.\d\d\d/) do devise_for :homebase_admin, :class_name => "Admin", :path => "homebase" end + + devise_for :skip_admin, :class_name => "Admin", :skip => :all # Routes for format=false testing devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]