Changeset 3459
- Timestamp:
- 01/22/06 01:52:23 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/redirect_test.rb (modified) (2 diffs)
- trunk/actionpack/test/template/url_helper_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3457 r3459 1 1 *SVN* 2 3 * Raise a RedirectBackError if redirect_to :back is called when there's no HTTP_REFERER defined #3049 [kevin.clark@gmail.com] 2 4 3 5 * Treat timestamps like datetimes for scaffolding purposes #3388 [Maik Schmidt] trunk/actionpack/lib/action_controller/base.rb
r3442 r3459 37 37 DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and only once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\". Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, explicitly, so \"render(...) and return false\"." 38 38 39 def initialize(message = nil) 40 super(message || DEFAULT_MESSAGE) 41 end 42 end 43 class RedirectBackError < ActionControllerError #:nodoc: 44 DEFAULT_MESSAGE = 'No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify @request.env["HTTP_REFERER"].' 45 39 46 def initialize(message = nil) 40 47 super(message || DEFAULT_MESSAGE) … … 781 788 782 789 when :back 783 re direct_to(request.env["HTTP_REFERER"])790 request.env["HTTP_REFERER"] ? redirect_to(request.env["HTTP_REFERER"]) : raise(RedirectBackError) 784 791 785 792 else trunk/actionpack/test/controller/redirect_test.rb
r2848 r3459 28 28 29 29 def rescue_errors(e) raise e end 30 31 def rescue_action(e) raise end 30 32 31 33 protected … … 77 79 assert_redirect_url "http://www.example.com/coming/from" 78 80 end 81 82 def test_redirect_to_back_with_no_referer 83 assert_raises(ActionController::RedirectBackError) { 84 @request.env["HTTP_REFERER"] = nil 85 get :redirect_to_back 86 } 87 end 79 88 end 80 89 trunk/actionpack/test/template/url_helper_test.rb
r2572 r3459 111 111 def test_link_tag_using_post_javascript 112 112 assert_dom_equal( 113 "<a href=\"http://www.example.com\" onclick=\" f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>",113 "<a href=\"http://www.example.com\" onclick=\"var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>", 114 114 link_to("Hello", "http://www.example.com", :post => true) 115 115 ) … … 118 118 def test_link_tag_using_post_javascript_and_confirm 119 119 assert_dom_equal( 120 "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>",120 "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>", 121 121 link_to("Hello", "http://www.example.com", :post => true, :confirm => "Are you serious?") 122 122 )