mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 16:18:04 -05:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7abe80e079 | ||
|
|
cf3e5c5d85 | ||
|
|
ef5cb5c34b | ||
|
|
09e815fa1c | ||
|
|
f72d7d85c7 | ||
|
|
994e62a533 | ||
|
|
18284d9ba3 | ||
|
|
9321db99a0 | ||
|
|
d9d9cf99e5 | ||
|
|
a3a142eb04 | ||
|
|
e4e6fb77bb | ||
|
|
0638a68704 | ||
|
|
a49f03e2f9 | ||
|
|
9b9924c9e5 | ||
|
|
7bfdd8e45e | ||
|
|
0a3181f42b | ||
|
|
cb990f2d28 | ||
|
|
fdb0cf11bb | ||
|
|
49db713b8f |
@@ -1,3 +1,13 @@
|
||||
== 1.0.9
|
||||
|
||||
* enhancements
|
||||
* Extracted redirect path from Devise failure app to a new method, allowing override in custom failure apps
|
||||
* Added sign_out_via
|
||||
|
||||
* bug fix
|
||||
* Email is now case insensitive
|
||||
* Avoid session fixation attacks
|
||||
|
||||
== 1.0.8
|
||||
|
||||
* enhancements
|
||||
|
||||
14
README.rdoc
14
README.rdoc
@@ -32,11 +32,11 @@ Devise is based on Warden (http://github.com/hassox/warden), a Rack Authenticati
|
||||
|
||||
Install warden gem if you don't have it installed:
|
||||
|
||||
sudo gem install warden
|
||||
gem install warden
|
||||
|
||||
Install devise gem:
|
||||
|
||||
sudo gem install devise --version=1.0.7
|
||||
gem install devise --version=1.0.8
|
||||
|
||||
Configure warden and devise gems inside your app:
|
||||
|
||||
@@ -240,6 +240,16 @@ Devise supports both ActiveRecord (default) and MongoMapper, and has experimenta
|
||||
|
||||
Please refer to TODO file.
|
||||
|
||||
== Security
|
||||
|
||||
Needless to say, security is extremely important to Devise. If you find yourself in a possible security issue with Devise, please go through the following steps, trying to reproduce the bug:
|
||||
|
||||
1) Look at the source code a bit to find out whether your assumptions are correct;
|
||||
2) If possible, provide a way to reproduce the bug: a small app on Github or a step-by-step to reproduce;
|
||||
3) E-mail us or send a Github private message instead of using the normal issues;
|
||||
|
||||
Being able to reproduce the bug is the first step to fix it. Thanks for your understanding.
|
||||
|
||||
== Maintainers
|
||||
|
||||
* José Valim (http://github.com/josevalim)
|
||||
|
||||
2
Rakefile
2
Rakefile
@@ -37,7 +37,7 @@ begin
|
||||
require 'jeweler'
|
||||
Jeweler::Tasks.new do |s|
|
||||
s.name = "devise"
|
||||
s.version = Devise::VERSION
|
||||
s.version = Devise::VERSION.dup
|
||||
s.summary = "Flexible authentication solution for Rails with Warden"
|
||||
s.email = "contact@plataformatec.com.br"
|
||||
s.homepage = "http://github.com/plataformatec/devise"
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{devise}
|
||||
s.version = "1.0.8"
|
||||
s.version = "1.0.9"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Jos\303\251 Valim", "Carlos Ant\303\264nio"]
|
||||
s.date = %q{2010-06-23}
|
||||
s.date = %q{2010-11-26}
|
||||
s.description = %q{Flexible authentication solution for Rails with Warden}
|
||||
s.email = %q{contact@plataformatec.com.br}
|
||||
s.extra_rdoc_files = [
|
||||
|
||||
@@ -183,7 +183,9 @@ module Devise
|
||||
|
||||
# Configure default url options to be used within Devise and ActionController.
|
||||
def default_url_options(&block)
|
||||
Devise::Mapping.metaclass.send :define_method, :default_url_options, &block
|
||||
who = Devise::Mapping.respond_to?(:singleton_class) ?
|
||||
Devise::Mapping.singleton_class : Devise::Mapping.metaclass
|
||||
who.send :define_method, :default_url_options, &block
|
||||
end
|
||||
|
||||
# A method used internally to setup warden manager from the Rails initialize
|
||||
|
||||
@@ -66,6 +66,7 @@ module Devise
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
resource ||= resource_or_scope
|
||||
warden.set_user(resource, :scope => scope)
|
||||
@_session = request.session # Recalculate session
|
||||
end
|
||||
|
||||
# Sign out a given user or scope. This helper is useful for signing out an user
|
||||
@@ -92,7 +93,8 @@ module Devise
|
||||
#
|
||||
def stored_location_for(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
session.delete(:"#{scope}.return_to")
|
||||
key = "#{scope}.return_to"
|
||||
session.delete(key) || session.delete(key.to_sym)
|
||||
end
|
||||
|
||||
# The default url to be used after signing in. This is used by all Devise
|
||||
@@ -105,13 +107,13 @@ module Devise
|
||||
#
|
||||
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
||||
#
|
||||
# map.resources :users do |users|
|
||||
# users.root # creates user_root_path
|
||||
# map.namespace :user do |user|
|
||||
# user.root :controller => 'users' # creates user_root_path
|
||||
# end
|
||||
#
|
||||
#
|
||||
# If none of these are defined, root_path is used. However, if this default
|
||||
# is not enough, you can customize it, for example:
|
||||
# If the resource root path is not defined, root_path is used. However,
|
||||
# if this default is not enough, you can customize it, for example:
|
||||
#
|
||||
# def after_sign_in_path_for(resource)
|
||||
# if resource.is_a?(User) && resource.can_publish?
|
||||
@@ -123,7 +125,7 @@ module Devise
|
||||
#
|
||||
def after_sign_in_path_for(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
home_path = :"#{scope}_root_path"
|
||||
home_path = "#{scope}_root_path"
|
||||
respond_to?(home_path, true) ? send(home_path) : root_path
|
||||
end
|
||||
|
||||
@@ -145,7 +147,11 @@ module Devise
|
||||
def sign_in_and_redirect(resource_or_scope, resource=nil, skip=false)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
resource ||= resource_or_scope
|
||||
sign_in(scope, resource) unless skip
|
||||
if skip
|
||||
@_session = request.session # Recalculate session
|
||||
else
|
||||
sign_in(scope, resource)
|
||||
end
|
||||
redirect_to stored_location_for(scope) || after_sign_in_path_for(resource)
|
||||
end
|
||||
|
||||
@@ -173,7 +179,7 @@ module Devise
|
||||
# user_signed_in? # Checks whether there is an user signed in or not
|
||||
# admin_signed_in? # Checks whether there is an admin signed in or not
|
||||
# current_user # Current signed in user
|
||||
# current_admin # Currend signed in admin
|
||||
# current_admin # Current signed in admin
|
||||
# user_session # Session data available only to the user scope
|
||||
# admin_session # Session data available only to the admin scope
|
||||
#
|
||||
|
||||
@@ -22,12 +22,8 @@ module Devise
|
||||
options = @env['warden.options']
|
||||
scope = options[:scope]
|
||||
|
||||
redirect_path = if mapping = Devise.mappings[scope]
|
||||
"#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}"
|
||||
else
|
||||
"/#{default_url}"
|
||||
end
|
||||
query_string = query_string_for(options)
|
||||
redirect_path = redirect_path_for(scope)
|
||||
query_string = query_string_for(options)
|
||||
store_location!(scope)
|
||||
|
||||
headers = {}
|
||||
@@ -54,6 +50,15 @@ module Devise
|
||||
Rack::Utils.build_query(params)
|
||||
end
|
||||
|
||||
# Build the path based on current scope.
|
||||
def redirect_path_for(scope)
|
||||
if mapping = Devise.mappings[scope]
|
||||
"#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}"
|
||||
else
|
||||
"/#{default_url}"
|
||||
end
|
||||
end
|
||||
|
||||
# Stores requested uri to redirect the user after signing in. We cannot use
|
||||
# scoped session provided by warden here, since the user is not authenticated
|
||||
# yet, but we still need to store the uri based on scope, so different scopes
|
||||
|
||||
@@ -22,7 +22,7 @@ module Devise
|
||||
# # is the modules included in the class
|
||||
#
|
||||
class Mapping #:nodoc:
|
||||
attr_reader :name, :as, :path_names, :path_prefix, :route_options
|
||||
attr_reader :name, :as, :path_names, :path_prefix, :route_options, :sign_out_via
|
||||
|
||||
# Loop through all mappings looking for a map that matches with the requested
|
||||
# path (ie /users/sign_in). If a path prefix is given, it's taken into account.
|
||||
@@ -64,6 +64,8 @@ module Devise
|
||||
|
||||
@path_names = Hash.new { |h,k| h[k] = k.to_s }
|
||||
@path_names.merge!(options.delete(:path_names) || {})
|
||||
|
||||
@sign_out_via = (options.delete(:sign_out_via) || :get)
|
||||
end
|
||||
|
||||
# Return modules for the mapping.
|
||||
@@ -96,7 +98,7 @@ module Devise
|
||||
|
||||
# Returns the parsed path taking into account the relative url root and raw path.
|
||||
def parsed_path
|
||||
returning (ActionController::Base.relative_url_root.to_s + raw_path) do |path|
|
||||
(ActionController::Base.relative_url_root.to_s + raw_path).tap do |path|
|
||||
self.class.default_url_options.each do |key, value|
|
||||
path.gsub!(key.inspect, value.to_param)
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ module Devise
|
||||
|
||||
# Send confirmation instructions by email
|
||||
def send_confirmation_instructions
|
||||
generate_confirmation_token if self.confirmation_token.nil?
|
||||
generate_confirmation_token! if self.confirmation_token.nil?
|
||||
::DeviseMailer.deliver_confirmation_instructions(self)
|
||||
end
|
||||
|
||||
@@ -135,6 +135,10 @@ module Devise
|
||||
self.confirmation_sent_at = Time.now.utc
|
||||
end
|
||||
|
||||
def generate_confirmation_token!
|
||||
generate_confirmation_token && save(false)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Attempt to find a user by it's email. If a record is found, send new
|
||||
# confirmation instructions to it. If not user is found, returns a new user
|
||||
|
||||
@@ -15,7 +15,7 @@ module Devise
|
||||
|
||||
base.class_eval do
|
||||
validates_presence_of :email
|
||||
validates_uniqueness_of :email, :scope => authentication_keys[1..-1], :allow_blank => true
|
||||
validates_uniqueness_of :email, :scope => authentication_keys[1..-1], :case_sensitive => false, :allow_blank => true
|
||||
validates_format_of :email, :with => EMAIL_REGEX, :allow_blank => true
|
||||
|
||||
with_options :if => :password_required? do |v|
|
||||
|
||||
@@ -66,6 +66,12 @@ module ActionController::Routing
|
||||
#
|
||||
# map.devise_for :users, :path_prefix => "/:locale"
|
||||
#
|
||||
# * :sign_out_via => restirct the HTTP method(s) accepted for the :sign_out action (default: :get), possible values are :post, :get, :put, :delete and :any, e.g. if you wish to restrict this to accept only :delete requests you should do:
|
||||
#
|
||||
# map.devise_for :users, :sign_out_via => :delete
|
||||
#
|
||||
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
|
||||
#
|
||||
# Any other options will be passed to route definition. If you need conditions for your routes, just map:
|
||||
#
|
||||
# map.devise_for :users, :conditions => { :subdomain => /.+/ }
|
||||
@@ -101,7 +107,9 @@ module ActionController::Routing
|
||||
routes.with_options(:controller => 'sessions', :name_prefix => nil) do |session|
|
||||
session.send(:"new_#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'new', :conditions => { :method => :get })
|
||||
session.send(:"#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'create', :conditions => { :method => :post })
|
||||
session.send(:"destroy_#{mapping.name}_session", mapping.path_names[:sign_out], :action => 'destroy', :conditions => { :method => :get })
|
||||
destroy_options = { :action => 'destroy' }
|
||||
destroy_options.merge! :conditions => { :method => mapping.sign_out_via } unless mapping.sign_out_via == :any
|
||||
session.send(:"destroy_#{mapping.name}_session", mapping.path_names[:sign_out], destroy_options)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -22,4 +22,39 @@ class Warden::SessionSerializer
|
||||
klass, id = keys
|
||||
klass.find(:first, :conditions => { :id => id })
|
||||
end
|
||||
end
|
||||
|
||||
class ActionController::Request
|
||||
def reset_session
|
||||
session.destroy if session && session.respond_to?(:destroy)
|
||||
self.session = {}
|
||||
end
|
||||
end
|
||||
|
||||
# Solve a bug in Rails where Set-Cookie is returning an array.
|
||||
class Devise::CookieSanitizer
|
||||
SET_COOKIE = "Set-Cookie".freeze
|
||||
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
response = @app.call(env)
|
||||
headers = response[1]
|
||||
headers[SET_COOKIE] = headers[SET_COOKIE].join("\n") if headers[SET_COOKIE].respond_to?(:join)
|
||||
response
|
||||
end
|
||||
end
|
||||
|
||||
Rails.configuration.middleware.insert_after ActionController::Failsafe, Devise::CookieSanitizer
|
||||
|
||||
Warden::Manager.after_set_user :event => [:set_user, :authentication] do |record, warden, options|
|
||||
if options[:scope] && warden.authenticated?(options[:scope])
|
||||
request = warden.request
|
||||
backup = request.session.to_hash
|
||||
backup.delete(:session_id)
|
||||
request.reset_session
|
||||
request.session.update(backup)
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,3 @@
|
||||
module Devise
|
||||
VERSION = "1.0.8".freeze
|
||||
VERSION = "1.0.9".freeze
|
||||
end
|
||||
|
||||
@@ -210,6 +210,17 @@ class AuthenticationTest < ActionController::IntegrationTest
|
||||
assert_equal "Cart", @controller.user_session[:cart]
|
||||
end
|
||||
|
||||
test 'session id is changed on sign in' do
|
||||
get '/users'
|
||||
session_id = request.session[:session_id]
|
||||
|
||||
get '/users'
|
||||
assert_equal session_id, request.session[:session_id]
|
||||
|
||||
sign_in_as_user
|
||||
assert_not_equal session_id, request.session[:session_id]
|
||||
end
|
||||
|
||||
test 'renders the scoped view if turned on and view is available' do
|
||||
swap Devise, :scoped_views => true do
|
||||
assert_raise Webrat::NotFoundError do
|
||||
@@ -269,3 +280,53 @@ class AuthenticationTest < ActionController::IntegrationTest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class AuthenticationSignOutViaTest < ActionController::IntegrationTest
|
||||
def sign_in!(scope)
|
||||
visit send("new_#{scope}_session_path")
|
||||
sign_in_as_user(:visit => false)
|
||||
assert warden.authenticated?(scope)
|
||||
end
|
||||
|
||||
test 'allow sign out via delete when sign_out_via provides only delete' do
|
||||
sign_in!(:sign_out_via_delete)
|
||||
delete destroy_sign_out_via_delete_session_path
|
||||
assert_not warden.authenticated?(:sign_out_via_delete)
|
||||
end
|
||||
|
||||
test 'do not allow sign out via get when sign_out_via provides only delete' do
|
||||
sign_in!(:sign_out_via_delete)
|
||||
get destroy_sign_out_via_delete_session_path
|
||||
assert warden.authenticated?(:sign_out_via_delete)
|
||||
end
|
||||
|
||||
test 'allow sign out via post when sign_out_via provides only post' do
|
||||
sign_in!(:sign_out_via_post)
|
||||
post destroy_sign_out_via_post_session_path
|
||||
assert_not warden.authenticated?(:sign_out_via_post)
|
||||
end
|
||||
|
||||
test 'do not allow sign out via get when sign_out_via provides only post' do
|
||||
sign_in!(:sign_out_via_post)
|
||||
get destroy_sign_out_via_delete_session_path
|
||||
assert warden.authenticated?(:sign_out_via_post)
|
||||
end
|
||||
|
||||
test 'allow sign out via delete when sign_out_via provides any method' do
|
||||
sign_in!(:sign_out_via_anymethod)
|
||||
delete destroy_sign_out_via_anymethod_session_path
|
||||
assert_not warden.authenticated?(:sign_out_via_anymethod)
|
||||
end
|
||||
|
||||
test 'allow sign out via post when sign_out_via provides any method' do
|
||||
sign_in!(:sign_out_via_anymethod)
|
||||
post destroy_sign_out_via_anymethod_session_path
|
||||
assert_not warden.authenticated?(:sign_out_via_anymethod)
|
||||
end
|
||||
|
||||
test 'allow sign out via get when sign_out_via provides any method' do
|
||||
sign_in!(:sign_out_via_anymethod)
|
||||
get destroy_sign_out_via_anymethod_session_path
|
||||
assert_not warden.authenticated?(:sign_out_via_anymethod)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -132,6 +132,16 @@ class MappingTest < ActiveSupport::TestCase
|
||||
assert_equal({ :requirements => { :extra => 'value' } }, Devise.mappings[:manager].route_options)
|
||||
end
|
||||
|
||||
test 'sign_out_via defaults to :get' do
|
||||
assert_equal :get, Devise.mappings[:user].sign_out_via
|
||||
end
|
||||
|
||||
test 'allows custom sign_out_via to be given' do
|
||||
assert_equal :delete, Devise.mappings[:sign_out_via_delete].sign_out_via
|
||||
assert_equal :post, Devise.mappings[:sign_out_via_post].sign_out_via
|
||||
assert_equal :any, Devise.mappings[:sign_out_via_anymethod].sign_out_via
|
||||
end
|
||||
|
||||
test 'magic predicates' do
|
||||
mapping = Devise.mappings[:user]
|
||||
assert mapping.authenticatable?
|
||||
|
||||
@@ -140,7 +140,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
user.instance_eval { def confirmation_required?; false end }
|
||||
user.save
|
||||
user.send_confirmation_instructions
|
||||
assert_not_nil user.confirmation_token
|
||||
assert_not_nil user.reload.confirmation_token
|
||||
end
|
||||
|
||||
test 'should not resend email instructions if the user change his email' do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'test/test_helper'
|
||||
|
||||
class Configurable < User
|
||||
devise :authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
|
||||
devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
|
||||
:stretches => 15, :pepper => 'abcdef', :confirm_within => 5.days,
|
||||
:remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":me
|
||||
ActiveRecord::Schema.define(:version => 1) do
|
||||
[:users, :admins, :accounts].each do |table|
|
||||
create_table table do |t|
|
||||
t.authenticatable :null => table == :admins
|
||||
t.database_authenticatable :null => table == :admins
|
||||
|
||||
if table != :admin
|
||||
t.string :username
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin < ActiveRecord::Base
|
||||
devise :authenticatable, :registerable, :timeoutable
|
||||
devise :database_authenticatable, :registerable, :timeoutable
|
||||
|
||||
def self.find_for_authentication(conditions)
|
||||
last(:conditions => conditions)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class User < ActiveRecord::Base
|
||||
devise :authenticatable, :http_authenticatable, :confirmable, :lockable, :recoverable,
|
||||
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
||||
:trackable, :validatable
|
||||
devise :database_authenticatable, :http_authenticatable, :confirmable,
|
||||
:lockable, :recoverable, :registerable, :rememberable, :timeoutable,
|
||||
:token_authenticatable, :trackable, :validatable
|
||||
|
||||
attr_accessible :username, :email, :password, :password_confirmation
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Be sure to restart your server when you modify this file
|
||||
|
||||
# Specifies gem version of Rails to use when vendor/rails is not present
|
||||
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
|
||||
RAILS_GEM_VERSION = '2.3.10' unless defined? RAILS_GEM_VERSION
|
||||
DEVISE_ORM = :active_record unless defined? DEVISE_ORM
|
||||
|
||||
# Bootstrap the Rails environment, frameworks, and default configuration
|
||||
@@ -13,7 +13,7 @@ Rails::Initializer.run do |config|
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
# Add additional load paths for your own custom dirs
|
||||
config.load_paths += [ "#{RAILS_ROOT}/app/#{DEVISE_ORM}/" ]
|
||||
config.autoload_paths += [ "#{RAILS_ROOT}/app/#{DEVISE_ORM}/" ]
|
||||
|
||||
# Specify gems that this application depends on and have them installed with rake gems:install
|
||||
# config.gem "bj"
|
||||
|
||||
@@ -12,6 +12,10 @@ ActionController::Routing::Routes.draw do |map|
|
||||
map.resources :admins, :only => :index
|
||||
map.root :controller => :home
|
||||
|
||||
map.devise_for :sign_out_via_deletes, :sign_out_via => :delete, :class_name => "User"
|
||||
map.devise_for :sign_out_via_posts, :sign_out_via => :post, :class_name => "User"
|
||||
map.devise_for :sign_out_via_anymethods, :sign_out_via => :any, :class_name => "User"
|
||||
|
||||
map.connect '/admin_area/password/new', :controller => "passwords", :action => "new"
|
||||
map.admin_root '/admin_area/home', :controller => "admins", :action => "index"
|
||||
|
||||
|
||||
@@ -107,4 +107,25 @@ class MapRoutingTest < ActionController::TestCase
|
||||
test 'map account with custom path name for registration' do
|
||||
assert_recognizes({:controller => 'registrations', :action => 'new', :locale => 'en', :extra => 'value'}, '/en/accounts/register')
|
||||
end
|
||||
|
||||
test 'map deletes with :sign_out_via option' do
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_deletes/sign_out', :method => :delete})
|
||||
assert_raise ActionController::MethodNotAllowed do
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_deletes/sign_out', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map posts with :sign_out_via option' do
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_posts/sign_out', :method => :post})
|
||||
assert_raise ActionController::MethodNotAllowed do
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_posts/sign_out', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map any methods with :sign_out_via option' do
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_anymethods/sign_out', :method => :get})
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_anymethods/sign_out', :method => :post})
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_anymethods/sign_out', :method => :delete})
|
||||
assert_recognizes({:controller => 'sessions', :action => 'destroy'}, {:path => '/sign_out_via_anymethods/sign_out', :method => :put})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user