There is a bug in the AbstractRequest getter/setter combo for the format. It was introduced in changeset 7479 a couple of months ago. It has escaped detection so far because the "respond_to |format|" circumvents it. The bug is trivial to understand and fix. Understanding: Assuming the request format (from Accept header) is initially not XML, this works as expected: request.format = :xml request.format.xml? => true ...but this does not: request.format.xml? => false request.format = :xml request.format.xml? => false The problem is that the getter caches the answer the first time it is invoked and subsequent changes with the setter don''t update the cache. The fix is trivial (see my ticket http://dev.rubyonrails.org/ticket/10889). But I am having a tough time writing a failing test. It seems as though TestRequest does not implement the getter/setter the same way as AbstractRequest. I''ve looked at mime_responds_test, and while it is easy enough to replicate the bug there, it seems like it is out of place as all the tests there are round trip tests. The obvious place is request_test, but I can''t get the @request instance variable to behave like the real thing -it doesn''t implement the setter the same way as the request. I would greatly appreciate it if someone could point me towards a testing mechanism. -Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-Jan-25 03:58 UTC
Re: Found bug, wrote patch. Need help with failing test.
> But I am having a tough time writing a failing test. It seems as > though TestRequest does not implement the getter/setter the same way > as AbstractRequest. I''ve looked at mime_responds_test, and while it > is easy enough to replicate the bug there, it seems like it is out of > place as all the tests there are round trip tests. The obvious place > is request_test, but I can''t get the @request instance variable to > behave like the real thing -it doesn''t implement the setter the same > way as the request. > > I would greatly appreciate it if someone could point me towards a > testing mechanism.Hey Chris, Sorry that it took a while to get back to you, jump into #rails-contrib and ask some of the folks hanging out in there. If we need to rejig the tests for that functionality, I''m sure we can hash it out pretty quickly. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Cruft
2008-Jan-25 16:57 UTC
Re: Found bug, wrote patch. Need help with failing test.
Thanks Michael. I did just that and Ben Scofield pointed me in the right direction. Can I get a +1? -Chris On Jan 24, 10:58 pm, "Michael Koziarski" <mich...@koziarski.com> wrote:> > But I am having a tough time writing a failing test. It seems as > > though TestRequest does not implement the getter/setter the same way > > as AbstractRequest. I''ve looked at mime_responds_test, and while it > > is easy enough to replicate the bug there, it seems like it is out of > > place as all the tests there are round trip tests. The obvious place > > is request_test, but I can''t get the @request instance variable to > > behave like the real thing -it doesn''t implement the setter the same > > way as the request. > > > I would greatly appreciate it if someone could point me towards a > > testing mechanism. > > Hey Chris, > > Sorry that it took a while to get back to you, jump into > #rails-contrib and ask some of the folks hanging out in there. If we > need to rejig the tests for that functionality, I''m sure we can hash > it out pretty quickly. > -- > Cheers > > Koz--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---