Merge pull request #1557 from plataformatec/rails-3-2-fixes

Rails 3.2 fixes
This commit is contained in:
José Valim 2012-01-10 12:26:58 -08:00
commit a43d1af23e
10 changed files with 96 additions and 59 deletions

View File

@ -4,7 +4,9 @@ rvm:
- 1.9.2
- 1.9.3
- ree
- rbx-18mode
gemfile:
- gemfiles/Gemfile.rails-3.1.x
- Gemfile
notifications:
recipients:
- jose.valim@plataformatec.com.br

View File

@ -2,7 +2,7 @@ source "http://rubygems.org"
gemspec
gem "rails", "~> 3.1.0"
gem "rails", ">= 3.2.0.rc", "< 4.0"
gem "omniauth", "~> 1.0.0"
gem "omniauth-oauth2", "~> 1.0.0"
gem "rdoc"

View File

@ -10,36 +10,35 @@ PATH
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.3)
actionpack (= 3.1.3)
actionmailer (3.2.0.rc2)
actionpack (= 3.2.0.rc2)
mail (~> 2.3.0)
actionpack (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
actionpack (3.2.0.rc2)
activemodel (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.5)
journey (~> 1.0.0.rc1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.3)
activemodel (3.1.3)
activesupport (= 3.1.3)
sprockets (~> 2.1.2)
activemodel (3.2.0.rc2)
activesupport (= 3.2.0.rc2)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
arel (~> 2.2.1)
activerecord (3.2.0.rc2)
activemodel (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
arel (~> 3.0.0.rc1)
tzinfo (~> 0.3.29)
activeresource (3.1.3)
activemodel (= 3.1.3)
activesupport (= 3.1.3)
activesupport (3.1.3)
activeresource (3.2.0.rc2)
activemodel (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
activesupport (3.2.0.rc2)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.6)
arel (2.2.1)
arel (3.0.0.rc1)
bcrypt-ruby (3.0.1)
bson (1.5.1)
bson_ext (1.3.1)
@ -53,7 +52,8 @@ GEM
hashie (1.2.0)
hike (1.2.1)
i18n (0.6.0)
json (1.6.3)
journey (1.0.0.rc4)
json (1.6.4)
linecache (0.46)
rbx-require-relative (> 0.0.4)
mail (2.3.0)
@ -89,11 +89,9 @@ GEM
rack-openid (~> 1.3.1)
orm_adapter (0.0.5)
polyglot (0.3.3)
rack (1.3.5)
rack (1.4.0)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
@ -101,24 +99,24 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.3)
actionmailer (= 3.1.3)
actionpack (= 3.1.3)
activerecord (= 3.1.3)
activeresource (= 3.1.3)
activesupport (= 3.1.3)
rails (3.2.0.rc2)
actionmailer (= 3.2.0.rc2)
actionpack (= 3.2.0.rc2)
activerecord (= 3.2.0.rc2)
activeresource (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
bundler (~> 1.0)
railties (= 3.1.3)
railties (3.1.3)
actionpack (= 3.1.3)
activesupport (= 3.1.3)
railties (= 3.2.0.rc2)
railties (3.2.0.rc2)
actionpack (= 3.2.0.rc2)
activesupport (= 3.2.0.rc2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rbx-require-relative (0.0.5)
rdoc (3.11)
rdoc (3.12)
json (~> 1.4)
ruby-debug (0.10.4)
columnize (>= 0.1)
@ -126,7 +124,7 @@ GEM
ruby-debug-base (0.10.4)
linecache (>= 0.3)
ruby-openid (2.1.8)
sprockets (2.0.3)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
@ -162,7 +160,7 @@ DEPENDENCIES
omniauth-facebook
omniauth-oauth2 (~> 1.0.0)
omniauth-openid (~> 1.0.1)
rails (~> 3.1.0)
rails (>= 3.2.0.rc, < 4.0)
rdoc
ruby-debug (>= 0.10.3)
sqlite3-ruby

View File

@ -14,13 +14,12 @@ Gem::Specification.new do |s|
s.rubyforge_project = "devise"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.files = Dir["CHANGELOG.rdoc", "MIT-LICENSE", "README.rdoc", "app/**/*", "config/**/*", "lib/**/*"]
s.test_files = Dir["test/**/*"]
s.require_paths = ["lib"]
s.add_dependency("warden", "~> 1.1")
s.add_dependency("orm_adapter", "~> 0.0.3")
s.add_dependency("bcrypt-ruby", "~> 3.0")
s.add_dependency("railties", "~> 3.1")
end
end

View File

@ -0,0 +1,35 @@
source "http://rubygems.org"
gem "devise", :path => ".."
gem "rails", "~> 3.1.0"
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.2", :require => false
gem "mocha", :require => false
platforms :mri_18 do
gem "ruby-debug", ">= 0.10.3"
end
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
end
platforms :ruby do
gem "sqlite3-ruby"
group :mongoid do
gem "mongo", "~> 1.3.0"
gem "mongoid", "~> 2.0"
gem "bson_ext", "~> 1.3.0"
end
end

View File

@ -105,7 +105,7 @@ module Devise
# Helper to decode credentials from HTTP.
def decode_credentials
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/m
ActiveSupport::Base64.decode64($1).split(/:/, 2)
Base64.decode64($1).split(/:/, 2)
end
# Sets the authentication hash and the password from params_auth_hash or http_auth_hash.
@ -156,4 +156,4 @@ module Devise
end
end
end
end
end

View File

@ -407,7 +407,10 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
test 'sign in stub in xml format' do
get new_user_session_path(:format => 'xml')
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>\n <email></email>\n <password nil=\"true\"></password>\n</user>\n", response.body
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
assert_match /<user>.*<\/user>/m, response.body
assert_match '<email></email>', response.body
assert_match '<password nil="true"></password>', response.body
end
test 'sign in stub in json format' do

View File

@ -4,7 +4,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
test 'handles unverified requests gets rid of caches but continues signed in' do
swap UsersController, :allow_forgery_protection => true do
create_user
post exhibit_user_url(1), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("user@test.com:123456")}"
post exhibit_user_url(1), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("user@test.com:123456")}"
assert warden.authenticated?(:user)
assert_equal "User is authenticated", response.body
end
@ -74,7 +74,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
token = "token_containing_so_many_characters_that_the_base64_encoding_will_wrap"
user = create_user
user.update_attribute :authentication_token, token
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{token}:x")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{token}:x")}"
assert_response :success
assert_match "<email>user@test.com</email>", response.body
assert warden.authenticated?(:user)
@ -84,14 +84,14 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
def sign_in_as_new_user_with_http(username="user@test.com", password="123456")
user = create_user
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{username}:#{password}")}"
user
end
# Sign in with oauth2 token. This is just to test that it isn't misinterpreted as basic authentication
def add_oauth2_header
user = create_user
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{ActiveSupport::Base64.encode64("#{user.email}:123456")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{Base64.encode64("#{user.email}:123456")}"
end
end

View File

@ -112,7 +112,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest
assert_not_equal user1, user2
visit users_path(Devise.token_authentication_key.to_s + '[$ne]' => user1.authentication_token)
assert_nil warden.user(:user)
assert_nil warden.user(:user)
end
end
@ -125,7 +125,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest
options[:auth_token] ||= user.authentication_token
if options[:http_auth]
header = "Basic #{ActiveSupport::Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}"
header = "Basic #{Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}"
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => header
else
visit users_path(options[:auth_token_key].to_sym => options[:auth_token])
@ -145,4 +145,4 @@ class TokenAuthenticationTest < ActionController::IntegrationTest
sign_in_as_new_user_with_token(:user => user)
end
end
end

View File

@ -36,11 +36,11 @@ class TrackableHooksTest < ActionController::IntegrationTest
assert_equal "127.0.0.1", user.current_sign_in_ip
assert_equal "127.0.0.1", user.last_sign_in_ip
end
test "current remote ip returns original ip behind a non transparent proxy" do
user = create_user
arbitrary_ip = '192.168.1.69'
arbitrary_ip = '200.121.1.69'
sign_in_as_user do
header 'HTTP_X_FORWARDED_FOR', arbitrary_ip
end
@ -72,7 +72,7 @@ class TrackableHooksTest < ActionController::IntegrationTest
assert_nil user.last_sign_in_at
end
end
test "do not track if devise.skip_trackable is set" do
user = create_user
sign_in_as_user do
@ -81,7 +81,7 @@ class TrackableHooksTest < ActionController::IntegrationTest
user.reload
assert_equal 0, user.sign_in_count
visit destroy_user_session_path
sign_in_as_user do
header 'devise.skip_trackable', false
end