Don't redirect XHR requests to /login.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11962 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2013-06-12 16:49:12 +00:00
parent 60d2a5e322
commit 136cdc765a
2 changed files with 23 additions and 1 deletions
@@ -136,4 +136,20 @@ class WelcomeControllerTest < ActionController::TestCase
assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
end
def test_unhautorized_exception_with_anonymous_should_redirect_to_login
WelcomeController.any_instance.stubs(:index).raises(::Unauthorized)
get :index
assert_response 302
assert_redirected_to('/login?back_url='+CGI.escape('http://test.host/'))
end
def test_unhautorized_exception_with_anonymous_and_xmlhttprequest_should_respond_with_401_to_anonymous
WelcomeController.any_instance.stubs(:index).raises(::Unauthorized)
@request.env["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest"
get :index
assert_response 401
end
end