Permalink
Browse files

Merged pull request #1041 from ecarnevale/master.

fix for issues #999: HTTP_ACCEPT=*/* should redirect to the default location
  • Loading branch information...
2 parents 4fd866d + 8e12ddf commit b03c93c4fe2f5a43f0990df557676dc033501723 @josevalim josevalim committed Apr 29, 2011
Showing with 8 additions and 1 deletion.
  1. +3 −1 lib/devise/failure_app.rb
  2. +5 −0 test/failure_app_test.rb
View
4 lib/devise/failure_app.rb
@@ -65,7 +65,9 @@ def i18n_message(default = nil)
end
def redirect_url
- if request_format == :html
+ if [:html, :"*/*", "*/*"].include? request_format
+ #if is_navigational_format?
+ #if request_format == :html
send(:"new_#{scope}_session_path")
else
send(:"new_#{scope}_session_path", :format => request_format)
View
5 test/failure_app_test.rb
@@ -39,6 +39,11 @@ def call_failure(env_params={})
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
end
+ test 'return to the default redirect location for wildcard requests' do
+ call_failure 'action_dispatch.request.formats' => nil, 'HTTP_ACCEPT' => '*/*'
+ assert_equal 'http://test.host/users/sign_in', @response.second['Location']
+ end
+
test 'uses the proxy failure message as symbol' do
call_failure('warden' => OpenStruct.new(:message => :test))
assert_equal 'test', @request.flash[:alert]

0 comments on commit b03c93c

Please sign in to comment.