1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Update bundler, Rails and improve tests for previous commit.

This commit is contained in:
José Valim 2010-07-02 08:12:00 +02:00
parent e9fbb3d7ef
commit 18cccae82f
7 changed files with 342 additions and 10 deletions

View file

@ -8,6 +8,7 @@
* bug fix
* Fix a bug in Devise::TestHelpers where current_user was returning a Response object for non active accounts
* Devise should respect script_name and path_info contracts
* Fix a bug when accessing a path with (.:format) (by github.com/klacointe)
== 1.1.rc2

317
Gemfile.lock Normal file
View file

@ -0,0 +1,317 @@
GIT
remote: git://github.com/datamapper/dm-core
revision: 40ff12e
specs:
dm-core (1.0.0)
addressable (~> 2.1)
extlib (~> 0.9.15)
dm-core (1.0.0)
addressable (~> 2.1)
extlib (~> 0.9.15)
GIT
remote: git://github.com/datamapper/dm-migrations
revision: c72ba40
specs:
dm-migrations (1.0.0)
dm-core (~> 1.0.0)
dm-migrations (1.0.0)
dm-core (~> 1.0.0)
GIT
remote: git://github.com/datamapper/dm-rails
revision: 8bf64e7
specs:
dm-rails (1.0.0)
actionpack (~> 3.0.0.beta3)
activesupport (~> 3.0.0.beta3)
dm-active_model (~> 1.0.0)
dm-core (~> 1.0.0)
railties (~> 3.0.0.beta3)
dm-rails (1.0.0)
actionpack (~> 3.0.0.beta3)
activesupport (~> 3.0.0.beta3)
dm-active_model (~> 1.0.0)
dm-core (~> 1.0.0)
railties (~> 3.0.0.beta3)
GIT
remote: git://github.com/datamapper/dm-serializer
revision: 1f0f617
specs:
dm-serializer (1.0.0)
dm-core (~> 1.0.0)
fastercsv (~> 1.5.3)
json_pure (~> 1.4.3)
dm-serializer (1.0.0)
dm-core (~> 1.0.0)
fastercsv (~> 1.5.3)
json_pure (~> 1.4.3)
GIT
remote: git://github.com/datamapper/dm-sqlite-adapter
revision: 2a8562b
specs:
dm-sqlite-adapter (1.0.0)
dm-do-adapter (~> 1.0.0)
do_sqlite3 (~> 0.10.2)
dm-sqlite-adapter (1.0.0)
dm-do-adapter (~> 1.0.0)
do_sqlite3 (~> 0.10.2)
GIT
remote: git://github.com/datamapper/dm-timestamps
revision: 791bad7
specs:
dm-timestamps (1.0.0)
dm-core (~> 1.0.0)
dm-timestamps (1.0.0)
dm-core (~> 1.0.0)
GIT
remote: git://github.com/datamapper/dm-validations
revision: c793091
specs:
dm-validations (1.0.0)
dm-core (~> 1.0.0)
dm-validations (1.0.0)
dm-core (~> 1.0.0)
GIT
remote: git://github.com/durran/mongoid.git
revision: 79b4d37
specs:
mongoid (2.0.0.beta7)
activemodel (~> 3.0.0.beta)
bson (~> 1.0.1)
mongo (~> 1.0.1)
tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
mongoid (2.0.0.beta7)
activemodel (~> 3.0.0.beta)
bson (~> 1.0.1)
mongo (~> 1.0.1)
tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
PATH
remote: /Users/jose/Work/github/rails
specs:
actionmailer (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
mail (~> 2.2.3)
actionmailer (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
mail (~> 2.2.3)
actionpack (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.16)
actionpack (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.16)
activemodel (3.0.0.beta4)
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activemodel (3.0.0.beta4)
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
arel (~> 0.4.0)
tzinfo (~> 0.3.16)
activerecord (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
arel (~> 0.4.0)
tzinfo (~> 0.3.16)
activeresource (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
activeresource (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
activesupport (3.0.0.beta4)
activesupport (3.0.0.beta4)
rails (3.0.0.beta4)
actionmailer (= 3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activerecord (= 3.0.0.beta4)
activeresource (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
bundler (>= 1.0.0.beta.2)
railties (= 3.0.0.beta4)
rails (3.0.0.beta4)
actionmailer (= 3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activerecord (= 3.0.0.beta4)
activeresource (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
bundler (>= 1.0.0.beta.2)
railties (= 3.0.0.beta4)
railties (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
rake (>= 0.8.3)
thor (~> 0.13.7)
railties (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
rake (>= 0.8.3)
thor (~> 0.13.7)
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
abstract (1.0.0)
addressable (2.1.2)
addressable (2.1.2)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
bcrypt-ruby (2.1.2)
bcrypt-ruby (2.1.2)
bson (1.0.3)
bson (1.0.3)
bson_ext (1.0.1)
bson_ext (1.0.1)
builder (2.1.2)
builder (2.1.2)
columnize (0.3.1)
columnize (0.3.1)
data_objects (0.10.2)
addressable (~> 2.1)
data_objects (0.10.2)
addressable (~> 2.1)
dm-active_model (1.0.0)
activemodel (~> 3.0.0.beta3)
dm-core (~> 1.0.0)
dm-active_model (1.0.0)
activemodel (~> 3.0.0.beta3)
dm-core (~> 1.0.0)
dm-do-adapter (1.0.0)
data_objects (~> 0.10.1)
dm-core (~> 1.0.0)
dm-do-adapter (1.0.0)
data_objects (~> 0.10.1)
dm-core (~> 1.0.0)
do_sqlite3 (0.10.2)
data_objects (= 0.10.2)
do_sqlite3 (0.10.2)
data_objects (= 0.10.2)
erubis (2.6.6)
abstract (>= 1.0.0)
erubis (2.6.6)
abstract (>= 1.0.0)
extlib (0.9.15)
extlib (0.9.15)
fastercsv (1.5.3)
fastercsv (1.5.3)
i18n (0.4.1)
i18n (0.4.1)
json_pure (1.4.3)
json_pure (1.4.3)
linecache (0.43)
linecache (0.43)
mail (2.2.5)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mail (2.2.5)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
mime-types (1.16)
mocha (0.9.8)
rake
mocha (0.9.8)
rake
mongo (1.0.3)
bson (= 1.0.3)
mongo (1.0.3)
bson (= 1.0.3)
nokogiri (1.4.2)
nokogiri (1.4.2)
polyglot (0.3.1)
polyglot (0.3.1)
rack (1.2.1)
rack (1.2.1)
rack-test (0.5.4)
rack (>= 1.0)
rack-test (0.5.4)
rack (>= 1.0)
rake (0.8.7)
rake (0.8.7)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
sqlite3-ruby (1.3.0)
sqlite3-ruby (1.3.0)
thor (0.13.7)
thor (0.13.7)
treetop (1.4.8)
polyglot (>= 0.3.1)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.22)
tzinfo (0.3.22)
warden (0.10.7)
rack (>= 1.0.0)
warden (0.10.7)
rack (>= 1.0.0)
webrat (0.7.0)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
webrat (0.7.0)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
will_paginate (3.0.pre)
will_paginate (3.0.pre)
PLATFORMS
ruby
DEPENDENCIES
bcrypt-ruby
bson_ext
dm-core (~> 1.0.0)!
dm-migrations (~> 1.0.0)!
dm-rails (~> 1.0.0)!
dm-serializer (~> 1.0.0)!
dm-sqlite-adapter (~> 1.0.0)!
dm-timestamps (~> 1.0.0)!
dm-validations (~> 1.0.0)!
mocha
mongo
mongoid!
rails!
ruby-debug (>= 0.10.3)
sqlite3-ruby
warden (= 0.10.7)
webrat (= 0.7.0)

View file

@ -39,7 +39,7 @@ module Devise
# Attempt to find the mapped route for devise based on request path
def devise_mapping
@devise_mapping ||= begin
mapping = Devise::Mapping.find_by_path(request.path_info)
mapping = Devise::Mapping.find_by_path(request)
mapping ||= Devise.mappings[Devise.default_scope] if Devise.use_default_scope
mapping
end

View file

@ -27,11 +27,15 @@ module Devise
# 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.
def self.find_by_path(path)
def self.find_by_path(request)
Devise.mappings.each_value do |mapping|
route = path.split("/")[mapping.segment_position]
route = route.sub(/\.\w+$/, '') unless route.nil?
return mapping if route && mapping.path == route.to_sym
route, extra = request.path_info.split("/")[mapping.segment_position, 2]
next unless route
if !extra && (format = request.params[:format])
route.sub!(/\.#{format}$/, '')
end
return mapping if mapping.path == route.to_sym
end
nil
end

View file

@ -1,6 +1,12 @@
require 'test_helper'
class FakeRequest < Struct.new(:path_info, :params)
end
class MappingTest < ActiveSupport::TestCase
def fake_request(path, params={})
FakeRequest.new(path, params)
end
test 'store options' do
mapping = Devise.mappings[:user]
@ -37,12 +43,16 @@ class MappingTest < ActiveSupport::TestCase
end
test 'find mapping by path' do
assert_nil Devise::Mapping.find_by_path("/foo/bar")
assert_equal Devise.mappings[:user], Devise::Mapping.find_by_path("/users/session")
assert_nil Devise::Mapping.find_by_path(fake_request("/foo/bar"))
assert_equal Devise.mappings[:user], Devise::Mapping.find_by_path(fake_request("/users/session"))
end
test 'find mapping by customized path' do
assert_equal Devise.mappings[:admin], Devise::Mapping.find_by_path("/admin_area/session")
assert_equal Devise.mappings[:admin], Devise::Mapping.find_by_path(fake_request("/admin_area/session"))
end
test 'find mapping by path strips format' do
assert_equal Devise.mappings[:user], Devise::Mapping.find_by_path(fake_request("/users.xml", :format => "xml"))
end
test 'find scope for a given object' do

View file

@ -7,4 +7,4 @@ require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
Rails::Application.load_tasks
Rails.application.load_tasks

View file

@ -1,4 +1,4 @@
Rails::Application.routes.draw do
Rails.application.routes.draw do
resources :users, :only => [:index] do
get :expire, :on => :member
get :accept, :on => :member