mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Let Devise play with both Rails 3.2 and Rails 4 for now
This commit is contained in:
parent
0fe0373144
commit
69f79ad446
13 changed files with 255 additions and 26 deletions
|
@ -6,6 +6,9 @@ rvm:
|
|||
env:
|
||||
- DEVISE_ORM=mongoid
|
||||
- DEVISE_ORM=active_record
|
||||
gemfile:
|
||||
- gemfiles/Gemfile.rails-3.2.x
|
||||
- Gemfile
|
||||
services:
|
||||
- mongodb
|
||||
notifications:
|
||||
|
|
|
@ -15,7 +15,7 @@ PATH
|
|||
devise (2.2.3)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (~> 4.0.0.rc1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
warden (~> 1.2.1)
|
||||
|
||||
GEM
|
||||
|
|
|
@ -22,5 +22,5 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency("warden", "~> 1.2.1")
|
||||
s.add_dependency("orm_adapter", "~> 0.1")
|
||||
s.add_dependency("bcrypt-ruby", "~> 3.0")
|
||||
s.add_dependency("railties", "~> 4.0.0.rc1")
|
||||
s.add_dependency("railties", ">= 3.2.6", "< 5")
|
||||
end
|
||||
|
|
31
gemfiles/Gemfile.rails-3.2.x
Normal file
31
gemfiles/Gemfile.rails-3.2.x
Normal file
|
@ -0,0 +1,31 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gemspec :path => '..'
|
||||
|
||||
gem "rails", "~> 3.2.6"
|
||||
gem "omniauth", "~> 1.0.0"
|
||||
gem "omniauth-oauth2", "~> 1.0.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", :require => false
|
||||
gem "mocha", "~> 0.13.1", :require => false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
gem "activerecord-jdbc-adapter"
|
||||
gem "activerecord-jdbcsqlite3-adapter"
|
||||
gem "jruby-openssl"
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
end
|
||||
|
||||
platforms :mri_19, :mri_20 do
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 3.0"
|
||||
end
|
||||
end
|
156
gemfiles/Gemfile.rails-3.2.x.lock
Normal file
156
gemfiles/Gemfile.rails-3.2.x.lock
Normal file
|
@ -0,0 +1,156 @@
|
|||
PATH
|
||||
remote: /Users/carlos/Projects/oss/devise
|
||||
specs:
|
||||
devise (2.2.3)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
warden (~> 1.2.1)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.13)
|
||||
actionpack (= 3.2.13)
|
||||
mail (~> 2.5.3)
|
||||
actionpack (3.2.13)
|
||||
activemodel (= 3.2.13)
|
||||
activesupport (= 3.2.13)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.4)
|
||||
rack (~> 1.4.5)
|
||||
rack-cache (~> 1.2)
|
||||
rack-test (~> 0.6.1)
|
||||
sprockets (~> 2.2.1)
|
||||
activemodel (3.2.13)
|
||||
activesupport (= 3.2.13)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.13)
|
||||
activemodel (= 3.2.13)
|
||||
activesupport (= 3.2.13)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.13)
|
||||
activemodel (= 3.2.13)
|
||||
activesupport (= 3.2.13)
|
||||
activesupport (3.2.13)
|
||||
i18n (= 0.6.1)
|
||||
multi_json (~> 1.0)
|
||||
arel (3.0.2)
|
||||
bcrypt-ruby (3.0.1)
|
||||
builder (3.0.4)
|
||||
erubis (2.7.0)
|
||||
faraday (0.8.7)
|
||||
multipart-post (~> 1.1)
|
||||
hashie (1.2.0)
|
||||
hike (1.2.2)
|
||||
httpauth (0.2.0)
|
||||
i18n (0.6.1)
|
||||
journey (1.0.4)
|
||||
json (1.7.7)
|
||||
jwt (0.1.8)
|
||||
multi_json (>= 1.5)
|
||||
mail (2.5.3)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.1)
|
||||
mime-types (1.23)
|
||||
mocha (0.13.3)
|
||||
metaclass (~> 0.0.1)
|
||||
mongoid (3.1.3)
|
||||
activemodel (~> 3.2)
|
||||
moped (~> 1.4.2)
|
||||
origin (~> 1.0)
|
||||
tzinfo (~> 0.3.22)
|
||||
moped (1.4.5)
|
||||
multi_json (1.7.2)
|
||||
multipart-post (1.2.0)
|
||||
nokogiri (1.5.9)
|
||||
oauth2 (0.8.1)
|
||||
faraday (~> 0.8)
|
||||
httpauth (~> 0.1)
|
||||
jwt (~> 0.1.4)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.0.3)
|
||||
hashie (~> 1.2)
|
||||
rack
|
||||
omniauth-facebook (1.4.0)
|
||||
omniauth-oauth2 (~> 1.0.2)
|
||||
omniauth-oauth2 (1.0.3)
|
||||
oauth2 (~> 0.8.0)
|
||||
omniauth (~> 1.0)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
origin (1.1.0)
|
||||
orm_adapter (0.4.0)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-ssl (1.3.3)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.13)
|
||||
actionmailer (= 3.2.13)
|
||||
actionpack (= 3.2.13)
|
||||
activerecord (= 3.2.13)
|
||||
activeresource (= 3.2.13)
|
||||
activesupport (= 3.2.13)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.13)
|
||||
railties (3.2.13)
|
||||
actionpack (= 3.2.13)
|
||||
activesupport (= 3.2.13)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.0.4)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
ruby-openid (2.2.3)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sqlite3 (1.3.7)
|
||||
thor (0.18.1)
|
||||
tilt (1.4.0)
|
||||
treetop (1.4.12)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.37)
|
||||
warden (1.2.1)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 0.13.1)
|
||||
mongoid (~> 3.0)
|
||||
omniauth (~> 1.0.0)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.0.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails (~> 3.2.6)
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
|
@ -35,10 +35,17 @@ class HelpersTest < ActionController::TestCase
|
|||
|
||||
test 'get resource params from request params using resource name as key' do
|
||||
user_params = {'email' => 'shirley@templar.com'}
|
||||
@controller.stubs(:params).returns(ActionController::Parameters.new({'user' => user_params}))
|
||||
# Stub controller name so strong parameters can filter properly.
|
||||
# DeviseController does not allow any parameters by default.
|
||||
@controller.stubs(:controller_name).returns(:sessions_controller)
|
||||
|
||||
params = if Devise.rails4?
|
||||
# Stub controller name so strong parameters can filter properly.
|
||||
# DeviseController does not allow any parameters by default.
|
||||
@controller.stubs(:controller_name).returns(:sessions_controller)
|
||||
|
||||
ActionController::Parameters.new({'user' => user_params})
|
||||
else
|
||||
HashWithIndifferentAccess.new({'user' => user_params})
|
||||
end
|
||||
@controller.stubs(:params).returns(params)
|
||||
|
||||
assert_equal user_params, @controller.send(:resource_params)
|
||||
end
|
||||
|
|
|
@ -153,7 +153,8 @@ class PasswordTest < ActionDispatch::IntegrationTest
|
|||
assert_response :success
|
||||
assert_current_url '/users/password'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain 'Password confirmation doesn\'t match Password'
|
||||
assert_contain Devise.rails4? ?
|
||||
"Password confirmation doesn't match Password" : "Password doesn't match confirmation"
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
||||
|
|
|
@ -100,7 +100,8 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|||
assert_template 'registrations/new'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain "Email is invalid"
|
||||
assert_contain "Password confirmation doesn't match Password"
|
||||
assert_contain Devise.rails4? ?
|
||||
"Password confirmation doesn't match Password" : "Password doesn't match confirmation"
|
||||
assert_contain "2 errors prohibited"
|
||||
assert_nil User.first
|
||||
|
||||
|
@ -206,7 +207,8 @@ class RegistrationTest < ActionDispatch::IntegrationTest
|
|||
fill_in 'current password', :with => '12345678'
|
||||
click_button 'Update'
|
||||
|
||||
assert_contain "Password confirmation doesn't match Password"
|
||||
assert_contain Devise.rails4? ?
|
||||
"Password confirmation doesn't match Password" : "Password doesn't match confirmation"
|
||||
assert_not User.first.valid_password?('pas123')
|
||||
end
|
||||
|
||||
|
|
|
@ -56,7 +56,12 @@ class ValidatableTest < ActiveSupport::TestCase
|
|||
test 'should require confirmation to be set when creating a new record' do
|
||||
user = new_user(:password => 'new_password', :password_confirmation => 'blabla')
|
||||
assert user.invalid?
|
||||
assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
|
||||
|
||||
if Devise.rails4?
|
||||
assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
|
||||
else
|
||||
assert_equal 'doesn\'t match confirmation', user.errors[:password].join
|
||||
end
|
||||
end
|
||||
|
||||
test 'should require password when updating/reseting password' do
|
||||
|
@ -73,7 +78,12 @@ class ValidatableTest < ActiveSupport::TestCase
|
|||
user = create_user
|
||||
user.password_confirmation = 'another_password'
|
||||
assert user.invalid?
|
||||
assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
|
||||
|
||||
if Devise.rails4?
|
||||
assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
|
||||
else
|
||||
assert_equal 'doesn\'t match confirmation', user.errors[:password].join
|
||||
end
|
||||
end
|
||||
|
||||
test 'should require a password with minimum of 6 characters' do
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class OmniAuthRoutesTest < ActionController::TestCase
|
||||
ExpectedUrlGeneratiorError = Devise.rails4? ?
|
||||
ActionController::UrlGenerationError : ActionController::RoutingError
|
||||
|
||||
tests ApplicationController
|
||||
|
||||
def assert_path(action, provider, with_param=true)
|
||||
|
@ -30,7 +33,7 @@ class OmniAuthRoutesTest < ActionController::TestCase
|
|||
test 'should generate authorization path' do
|
||||
assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
|
||||
|
||||
assert_raise ActionController::UrlGenerationError do
|
||||
assert_raise ExpectedUrlGeneratiorError do
|
||||
@controller.omniauth_authorize_path(:user, :github)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1,8 @@
|
|||
RailsApp::Application.config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10'
|
||||
config = Rails.application.config
|
||||
|
||||
if Devise.rails4?
|
||||
config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10'
|
||||
else
|
||||
config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
|
||||
config.session_store :cookie_store, :key => "_my_app"
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
ExpectedRoutingError = Devise.rails4? ? MiniTest::Assertion : ActionController::RoutingError
|
||||
|
||||
class DefaultRoutingTest < ActionController::TestCase
|
||||
test 'map new user session' do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => 'users/sign_in', :method => :get})
|
||||
|
@ -101,7 +103,7 @@ class DefaultRoutingTest < ActionController::TestCase
|
|||
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :post})
|
||||
assert_named_route "/users/auth/google/callback", :user_omniauth_callback_path, :google
|
||||
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'ysers/omniauth_callbacks', :action => 'twitter'}, {:path => 'users/auth/twitter/callback', :method => :get})
|
||||
end
|
||||
end
|
||||
|
@ -123,7 +125,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
test 'does not map admin password' do
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'admin_area/password/new')
|
||||
end
|
||||
end
|
||||
|
@ -133,7 +135,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
test 'does only map reader password' do
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, 'reader/sessions/new')
|
||||
end
|
||||
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'reader/password/new')
|
||||
|
@ -161,14 +163,14 @@ class CustomizedRoutingTest < ActionController::TestCase
|
|||
|
||||
test 'map deletes with :sign_out_via option' do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :delete})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/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 => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :post})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :get})
|
||||
end
|
||||
end
|
||||
|
@ -176,56 +178,56 @@ class CustomizedRoutingTest < ActionController::TestCase
|
|||
test 'map delete_or_posts with :sign_out_via option' do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :post})
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :delete})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with constraints defined in hash' do
|
||||
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/headquarters/sign_up', :method => :get})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100/headquarters/sign_up', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with constraints defined in block' do
|
||||
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/homebase/sign_up', :method => :get})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100//homebase/sign_up', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with format false for sessions' do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in', :method => :get})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in.xml', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with format false for passwords' do
|
||||
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password', :method => :post})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password.xml', :method => :post})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with format false for registrations' do
|
||||
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up', :method => :get})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up.xml', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with format false for confirmations' do
|
||||
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation', :method => :get})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation.xml', :method => :get})
|
||||
end
|
||||
end
|
||||
|
||||
test 'map with format false for unlocks' do
|
||||
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock', :method => :get})
|
||||
assert_raise Assertion do
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock.xml', :method => :get})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,13 @@ DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
|
|||
$:.unshift File.dirname(__FILE__)
|
||||
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
|
||||
|
||||
module Devise
|
||||
# Detection for minor differences between Rails 3.2 and 4 in tests.
|
||||
def self.rails4?
|
||||
Rails.version.start_with? '4'
|
||||
end
|
||||
end
|
||||
|
||||
require "rails_app/config/environment"
|
||||
require "rails/test_help"
|
||||
require "orm/#{DEVISE_ORM}"
|
||||
|
|
Loading…
Reference in a new issue