#253 ✓resolved
Piers Cawley

Core::Session#redirect? fragile in the face of rationals

Reported by Piers Cawley | May 27th, 2009 @ 07:49 AM

#redirect? works by doing

status / 100 == 3

which is fine, until someone loads a gem like ruby-units which monkey patches Integer#/ to return a Rational rather than an integer. Obvious fix is at:

http://github.com/pdcawley/webrat/commit/58601c4653fd92bbfb87c8b350...

I'm not entirely sure how to write a test that exposes this without adding a dependency, which seems like overkill for an obvious implementation type solution.

Comments and changes to this ticket

  • gaffo

    gaffo May 28th, 2009 @ 07:13 PM

    • Tag set to bugfix, test!
    • State changed from “new” to “open”

    The test would be to mixin the rationality patch to the response code spec or just spec out that response code is rational.

    Do you have a library that is actually doing this just FMI?

  • Piers Cawley

    Piers Cawley May 28th, 2009 @ 11:40 PM

    Yup. That's how I found the bug in the first place. And ruby-units is just too damned useful to give it up.

  • gaffo

    gaffo May 29th, 2009 @ 10:43 AM

    • State changed from “open” to “awaiting-patch”

    Well, I guess, toss in the test where you expect or change a specific int to behave rationally and I'll take a look.

    Thanks!

  • Bryan Helmkamp

    Bryan Helmkamp June 14th, 2009 @ 10:07 PM

    • State changed from “awaiting-patch” to “resolved”

    Thanks for the patch, Piers. I've merged it into master.

    Here's what I did for a spec:

    http://github.com/brynary/webrat/commit/f8af783185313faf6cda7fa16e6...

    It's a little scary, but it seems to work. Also and interestingly: If that spec fails, Fixnum never gets restored to its original behavior. Not sure if there's a clean way to deal with that.

    Cheers,

    -Bryan

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Tags

Pages