Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4294 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Hash#diff; and show a diff with assert_redirected_to

Reported by: court3nay Assigned to: David
Priority: normal Milestone:
Component: ActiveSupport Version: 1.0.0
Severity: normal Keywords:
Cc: court3nay@gmail.com

Description

I hate having to hunt through redirect responses. With the help of Chris McGrath, who wrote the diff function, and told me how to rescue an assertion, here's a nicer assert_redirected_to message.

assert_redirected_to :action => 'other_host', :only_path => false
  when it was expecting
redirected_to :action => 'other_host', :only_path => true, :host => 'other.test.host'
  gives the error message

response is not a redirection to all of the options supplied (redirection is <{:only_path=>false, :host=>"other.test.host", :action=>"other_host"}>), difference: <{:only_path=>"true", :host=>"other.test.host"}>

which is much nicer IMO. With full tests.

Attachments

hash_diff_on_redirect.diff (4.2 kB) - added by court3nay on 03/18/06 02:20:01.
patch
diff_assert_redirected_to.diff (10.5 kB) - added by rick on 03/20/06 23:05:47.
updated to work with symbols (named routes) and strings passed to assert_redirected_to

Change History

03/18/06 02:20:01 changed by court3nay

  • attachment hash_diff_on_redirect.diff added.

patch

03/19/06 03:50:21 changed by rick

  • status changed from new to closed.
  • resolution set to fixed.

(In [3969]) Added nicer message for assert_redirected_to (closes #4294) [court3nay, Chris McGrath]

03/20/06 23:05:47 changed by rick

  • attachment diff_assert_redirected_to.diff added.

updated to work with symbols (named routes) and strings passed to assert_redirected_to