Permalink
Browse files

render with cache options are passed on to cache.write

  • Loading branch information...
1 parent 0912172 commit fedadd2b69f9b1d2c6b9340c8c426ce859d890ca @ryanb committed Jun 19, 2008
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/render_caching/controller_additions.rb
  2. +5 −0 spec/render_caching/controller_additions_spec.rb
@@ -2,15 +2,15 @@ module RenderCaching
module ControllerAdditions
private
- def render_with_cache(key = nil)
+ def render_with_cache(key = nil, options = nil)
key ||= request.request_uri
body = Rails.cache.read(key)
if body
render :text => body
else
yield if block_given?
render unless performed?
- Rails.cache.write(key, response.body)
+ Rails.cache.write(key, response.body, options)
end
end
end
@@ -74,4 +74,9 @@ def self.cache
Rails.cache.write('some_key', 'page content')
render_with_cache('some_key') { violated('block was executed') }
end
+
+ it "should pass options to cache write call" do
+ Rails.cache.expects(:write).with('some_key', @response.body, :expires_in => 5)
+ render_with_cache('some_key', :expires_in => 5)
+ end
end

0 comments on commit fedadd2

Please sign in to comment.