verify :redirect_to => :back should redirect to the referrer. [#280 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
parent
322f3eacf9
commit
1b4b8fbbd9
|
@ -116,7 +116,7 @@ module ActionController #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_redirect_to(redirect_to_option) # :nodoc:
|
def apply_redirect_to(redirect_to_option) # :nodoc:
|
||||||
redirect_to_option.is_a?(Symbol) ? self.send!(redirect_to_option) : redirect_to_option
|
(redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.send!(redirect_to_option) : redirect_to_option
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_remaining_actions(options) # :nodoc:
|
def apply_remaining_actions(options) # :nodoc:
|
||||||
|
|
|
@ -39,6 +39,9 @@ class VerificationTest < Test::Unit::TestCase
|
||||||
|
|
||||||
verify :only => :no_default_action, :params => "santa"
|
verify :only => :no_default_action, :params => "santa"
|
||||||
|
|
||||||
|
verify :only => :guarded_with_back, :method => :post,
|
||||||
|
:redirect_to => :back
|
||||||
|
|
||||||
def guarded_one
|
def guarded_one
|
||||||
render :text => "#{params[:one]}"
|
render :text => "#{params[:one]}"
|
||||||
end
|
end
|
||||||
|
@ -91,6 +94,10 @@ class VerificationTest < Test::Unit::TestCase
|
||||||
render :text => "Was a post!"
|
render :text => "Was a post!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def guarded_with_back
|
||||||
|
render :text => "#{params[:one]}"
|
||||||
|
end
|
||||||
|
|
||||||
def no_default_action
|
def no_default_action
|
||||||
# Will never run
|
# Will never run
|
||||||
end
|
end
|
||||||
|
@ -110,6 +117,16 @@ class VerificationTest < Test::Unit::TestCase
|
||||||
ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo'
|
ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_using_symbol_back_with_no_referrer
|
||||||
|
assert_raise(ActionController::RedirectBackError) { get :guarded_with_back }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_using_symbol_back_redirects_to_referrer
|
||||||
|
@request.env["HTTP_REFERER"] = "/foo"
|
||||||
|
get :guarded_with_back
|
||||||
|
assert_redirected_to '/foo'
|
||||||
|
end
|
||||||
|
|
||||||
def test_no_deprecation_warning_for_named_route
|
def test_no_deprecation_warning_for_named_route
|
||||||
assert_not_deprecated do
|
assert_not_deprecated do
|
||||||
get :guarded_one_for_named_route_test, :two => "not one"
|
get :guarded_one_for_named_route_test, :two => "not one"
|
||||||
|
|
Loading…
Reference in New Issue