rails/jbuilder — pull request #138 by rewritten (2013-06-28 09:56:27+00:00)
Title: Skip cache when the controller as `perform_caching = false`

The documentation in `JbuilderTemplate#cache!` says:

# Caches the json constructed within the block passed. Has the same signature as the `cache` helper
# method in `ActionView::Helpers::CacheHelper` and so can be used in the same way.

This is not true, as the `controller.perform_caching` check it's implemented as a forced miss. A forced miss implies a cache write, when the normal view cache helpers use

return content unless cache_configured?

which skips completely the cache when the controller says so.

This change solves the issue.

(test included)