<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/app/views/welcome/with_cached_block.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -49,7 +49,10 @@ module SimplesIdeias::Cached::ActionPack
         # check if layout is meant to be cached
         cache_layout = !!options.delete(:layout)
         
-        if requested_page = Cache.read(key)
+        # should I cache everything?
+        perform_caching = ::ActionController::Base.perform_caching
+        
+        if perform_caching &amp;&amp; requested_page = Cache.read(key)
           render :text =&gt; requested_page, :layout =&gt; !cache_layout
         else
           yield if block_given?
@@ -61,7 +64,7 @@ module SimplesIdeias::Cached::ActionPack
             render :text =&gt; contents, :layout =&gt; !cache_layout
           end
           
-          Cache.write(key, contents, options) if ::ActionController::Base.perform_caching
+          Cache.write(key, contents, options) if perform_caching
         end
       end
     end</diff>
      <filename>lib/action_pack.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-log/*
+log/*.log
 tmp/*
 db/*.sqlite3
 vendor/plugins/*
\ No newline at end of file</diff>
      <filename>test/.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,3 @@
-# ActionController::Base.perform_caching = true
-
 class WelcomeController &lt; ApplicationController
   def without_layout
     cached_render :expires_in =&gt; 15.minutes
@@ -8,4 +6,7 @@ class WelcomeController &lt; ApplicationController
   def with_layout
     cached_render :expires_in =&gt; 15.minutes, :layout =&gt; true
   end
+  
+  def with_cached_block
+  end
 end</diff>
      <filename>test/app/controllers/welcome_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ config.whiny_nils = true
 # Show full error reports and disable caching
 config.action_controller.consider_all_requests_local = true
 config.action_view.debug_rjs                         = true
-config.action_controller.perform_caching             = false
+config.action_controller.perform_caching             = true
 
 # Don't care if the mailer can't send
 config.action_mailer.raise_delivery_errors = false
\ No newline at end of file</diff>
      <filename>test/config/environments/development.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,38 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 describe WelcomeController do
   integrate_views
   
+  before(:each) do
+    # expire each key before running tests
+    %w(render/welcome/without_layout render/welcome/with_layout block/date).each do |key|
+      Cache.delete(key)
+    end
+  end
+  
+  describe &quot;with blocks&quot; do
+    before(:each) do
+      @now = Time.now
+      @after = 15.minutes.from_now
+      
+      Time.stub!(:now).and_return(@now)
+      ActionController::Base.perform_caching = true
+      
+      get :with_cached_block
+    end
+    
+    it &quot;should cache block only&quot; do
+      @response.body.should have_tag('h1', @now.to_s(:db))
+      @response.body.should have_tag('h2', @now.to_s(:db))
+      @response.body.should have_tag('h3', @now.to_s(:db))
+      
+      Time.stub!(:now).and_return(@after)
+      get :with_cached_block
+      
+      @response.body.should have_tag('h1', @after.to_s(:db))
+      @response.body.should have_tag('h2', @after.to_s(:db))
+      @response.body.should have_tag('h3', @now.to_s(:db))
+    end
+  end
+  
   describe &quot;with layouts&quot; do
     before(:each) do
       @now = Time.now
@@ -80,8 +112,10 @@ describe WelcomeController do
     
     it &quot;should not cache view&quot; do
       @response.body.should have_tag('h2', @now.to_s(:db))
+      
       Time.stub!(:now).and_return(@after)
       get :without_layout
+      
       @response.body.should have_tag('h2', @after.to_s(:db))
     end
   end</diff>
      <filename>test/spec/controllers/welcome_controller_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/log/development.log</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>eb856bc0bdfb9d3f3da4d767539af408b1b89f43</id>
    </parent>
  </parents>
  <author>
    <name>Nando Vieira</name>
    <email>fnando.vieira@gmail.com</email>
  </author>
  <url>http://github.com/fnando/has_cache/commit/8a13d170a7bd299fcd351d768a9b861765b7d059</url>
  <id>8a13d170a7bd299fcd351d768a9b861765b7d059</id>
  <committed-date>2008-10-29T03:15:33-07:00</committed-date>
  <authored-date>2008-10-29T03:15:33-07:00</authored-date>
  <message>Added specs for cached_block</message>
  <tree>8d41f0a8736feef2b8104951be0bc51fc4eb145c</tree>
  <committer>
    <name>Nando Vieira</name>
    <email>fnando.vieira@gmail.com</email>
  </committer>
</commit>
