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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to