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