From add8f8a20335041d616aa259ea173b45116ec45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 15 Feb 2011 10:26:28 +0100 Subject: [PATCH] Works on 3.0.4. --- Gemfile | 2 +- Gemfile.lock | 102 +++++++++++++++-------------- lib/devise.rb | 3 +- lib/devise/failure_app.rb | 11 ++-- lib/generators/templates/devise.rb | 5 +- test/failure_app_test.rb | 2 +- 6 files changed, 66 insertions(+), 59 deletions(-) diff --git a/Gemfile b/Gemfile index 9a3c3e75..d7f125cc 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" gemspec -gem "rails", "~> 3.0.0" +gem "rails", "~> 3.0.4" gem "oa-oauth", :require => "omniauth/oauth" gem "oa-openid", :require => "omniauth/openid" diff --git a/Gemfile.lock b/Gemfile.lock index f9f306ea..ef9c3061 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,60 +10,60 @@ GEM remote: http://rubygems.org/ specs: abstract (1.0.0) - actionmailer (3.0.3) - actionpack (= 3.0.3) - mail (~> 2.2.9) - actionpack (3.0.3) - activemodel (= 3.0.3) - activesupport (= 3.0.3) + actionmailer (3.0.4) + actionpack (= 3.0.4) + mail (~> 2.2.15) + actionpack (3.0.4) + activemodel (= 3.0.4) + activesupport (= 3.0.4) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.4) rack (~> 1.2.1) rack-mount (~> 0.6.13) - rack-test (~> 0.5.6) + rack-test (~> 0.5.7) tzinfo (~> 0.3.23) - activemodel (3.0.3) - activesupport (= 3.0.3) + activemodel (3.0.4) + activesupport (= 3.0.4) builder (~> 2.1.2) i18n (~> 0.4) - activerecord (3.0.3) - activemodel (= 3.0.3) - activesupport (= 3.0.3) + activerecord (3.0.4) + activemodel (= 3.0.4) + activesupport (= 3.0.4) arel (~> 2.0.2) tzinfo (~> 0.3.23) - activerecord-jdbc-adapter (1.0.2-java) - activerecord-jdbcsqlite3-adapter (1.0.2-java) - activerecord-jdbc-adapter (= 1.0.2) + activerecord-jdbc-adapter (1.1.1) + activerecord-jdbcsqlite3-adapter (1.1.1) + activerecord-jdbc-adapter (= 1.1.1) jdbc-sqlite3 (~> 3.6.0) - activeresource (3.0.3) - activemodel (= 3.0.3) - activesupport (= 3.0.3) - activesupport (3.0.3) - addressable (2.2.2) - arel (2.0.4) - bcrypt-ruby (2.1.2) - bson (1.1.2) + activeresource (3.0.4) + activemodel (= 3.0.4) + activesupport (= 3.0.4) + activesupport (3.0.4) + addressable (2.2.4) + arel (2.0.8) + bcrypt-ruby (2.1.4) + bcrypt-ruby (2.1.4-java) + bson (1.2.1) bson_ext (1.1.2) builder (2.1.2) columnize (0.3.2) erubis (2.6.6) abstract (>= 1.0.0) - faraday (0.5.2) - addressable (~> 2.2.2) - multipart-post (~> 1.0.1) + faraday (0.5.5) + addressable (~> 2.2.4) + multipart-post (~> 1.1.0) rack (>= 1.1.0, < 2) - i18n (0.4.2) + i18n (0.5.0) jdbc-sqlite3 (3.6.14.2.056-java) linecache (0.43) - mail (2.2.10) + mail (2.2.15) activesupport (>= 2.3.6) - i18n (~> 0.4.1) + i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.16) - mocha (0.9.9) - rake + mocha (0.9.12) mongo (1.1.2) bson (>= 1.1.1) mongoid (2.0.0.beta.20) @@ -72,9 +72,9 @@ GEM tzinfo (~> 0.3.22) will_paginate (~> 3.0.pre) multi_json (0.0.5) - multipart-post (1.0.1) - nokogiri (1.4.3.1) - nokogiri (1.4.3.1-java) + multipart-post (1.1.0) + nokogiri (1.4.4) + nokogiri (1.4.4-java) weakling (>= 0.0.3) oa-core (0.1.6) rack (~> 1.1) @@ -89,10 +89,10 @@ GEM rack-openid (~> 1.2.0) ruby-openid-apps-discovery oauth (0.4.4) - oauth2 (0.1.0) + oauth2 (0.1.1) faraday (~> 0.5.0) multi_json (~> 0.0.4) - orm_adapter (0.0.3) + orm_adapter (0.0.4) polyglot (0.3.1) rack (1.2.1) rack-mount (0.6.13) @@ -100,19 +100,19 @@ GEM rack-openid (1.2.0) rack (>= 1.1.0) ruby-openid (>= 2.1.8) - rack-test (0.5.6) + rack-test (0.5.7) rack (>= 1.0) - rails (3.0.3) - actionmailer (= 3.0.3) - actionpack (= 3.0.3) - activerecord (= 3.0.3) - activeresource (= 3.0.3) - activesupport (= 3.0.3) + rails (3.0.4) + actionmailer (= 3.0.4) + actionpack (= 3.0.4) + activerecord (= 3.0.4) + activeresource (= 3.0.4) + activesupport (= 3.0.4) bundler (~> 1.0) - railties (= 3.0.3) - railties (3.0.3) - actionpack (= 3.0.3) - activesupport (= 3.0.3) + railties (= 3.0.4) + railties (3.0.4) + actionpack (= 3.0.4) + activesupport (= 3.0.4) rake (>= 0.8.7) thor (~> 0.14.4) rake (0.8.7) @@ -124,11 +124,13 @@ GEM ruby-openid (2.1.8) ruby-openid-apps-discovery (1.2.0) ruby-openid (>= 2.1.7) - sqlite3-ruby (1.3.2) + sqlite3 (1.3.3) + sqlite3-ruby (1.3.3) + sqlite3 (>= 1.3.3) thor (0.14.6) treetop (1.4.9) polyglot (>= 0.3.1) - tzinfo (0.3.23) + tzinfo (0.3.24) warden (1.0.3) rack (>= 1.0.0) weakling (0.0.4-java) @@ -153,7 +155,7 @@ DEPENDENCIES oa-oauth oa-openid orm_adapter (~> 0.0.3) - rails (~> 3.0.0) + rails (~> 3.0.4) ruby-debug (>= 0.10.3) sqlite3-ruby warden (~> 1.0.3) diff --git a/lib/devise.rb b/lib/devise.rb index fd6e9c91..7b93ee0c 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -187,8 +187,9 @@ module Devise @@stateless_token = false # Which formats should be treated as navigational. + # We need both :"*/*" and "*/*" to work on different Rails versions. mattr_accessor :navigational_formats - @@navigational_formats = [:"*/*", :html] + @@navigational_formats = [:"*/*", "*/*", :html] # When set to true, signing out a user signs out all other scopes. mattr_accessor :sign_out_all_scopes diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb index efe92735..d4a95982 100644 --- a/lib/devise/failure_app.rb +++ b/lib/devise/failure_app.rb @@ -64,7 +64,6 @@ module Devise end def redirect_url - request_format = request.format.to_sym if request_format == :html send(:"new_#{scope}_session_path") else @@ -84,7 +83,7 @@ module Devise if request.xhr? Devise.http_authenticatable_on_xhr else - !(request.format && Devise.navigational_formats.include?(request.format.to_sym)) + !(request_format && Devise.navigational_formats.include?(request_format)) end end @@ -95,8 +94,8 @@ module Devise end def http_auth_body - return i18n_message unless request.format - method = "to_#{request.format.to_sym}" + return i18n_message unless request_format + method = "to_#{request_format}" {}.respond_to?(method) ? { :error => i18n_message }.send(method) : i18n_message end @@ -128,5 +127,9 @@ module Devise def store_location! session["#{scope}_return_to"] = attempted_path if request.get? && !http_auth? end + + def request_format + @request_format ||= request.format.respond_to?(:ref) ? request.format.ref : request.format + end end end diff --git a/lib/generators/templates/devise.rb b/lib/generators/templates/devise.rb index 35f0fd58..e1b775c7 100644 --- a/lib/generators/templates/devise.rb +++ b/lib/generators/templates/devise.rb @@ -161,8 +161,9 @@ Devise.setup do |config| # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # - # The :"*/*" format below is required to match Internet Explorer requests. - # config.navigational_formats = [:"*/*", :html] + # The :"*/*" and "*/*" formats below is required to match Internet + # Explorer requests. + # config.navigational_formats = [:"*/*", "*/*", :html] # The default HTTP method used to sign out a resource. Default is :get. # config.sign_out_via = :get diff --git a/test/failure_app_test.rb b/test/failure_app_test.rb index 31de92c8..c4e1cfaf 100644 --- a/test/failure_app_test.rb +++ b/test/failure_app_test.rb @@ -13,7 +13,7 @@ class FailureTest < ActiveSupport::TestCase 'REQUEST_METHOD' => 'GET', 'warden.options' => { :scope => :user }, 'rack.session' => {}, - 'action_dispatch.request.formats' => Array(env_params.delete('formats') || :html), + 'action_dispatch.request.formats' => Array(env_params.delete('formats') || Mime::HTML), 'rack.input' => "", 'warden' => OpenStruct.new(:message => nil) }.merge!(env_params)