How to test rails ETag caching?

Posted by ifesdjeen on Stack Overflow See other posts from Stack Overflow or by ifesdjeen
Published on 2010-04-15T10:12:14Z Indexed on 2010/04/15 10:23 UTC
Read the original article Hit count: 522

Filed under:
|
|

Hi,

Is it possible to cover my controller, that is highly depeinding on Etags with unit tests?

Here's what i'm trying to do: in case if page is not stale (meaning that it's fresh), i'm adding some header to response.

When i'm trying to test it all (rspec), no matter how many similar requests i have, i still receive 200 OK instead of 304, and my header doesn't get modified. Furthermore, if i track request.fresh?(response), it's ALWAYS false.

However, it perfectly works in browser. I've already tried to state ActionController::Base.perform_caching = true, it doesn't change the overall situation.

Thank you

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about etag