Permalink
Browse files

Making the cake:nocache stripping more relaxed so that if either cond…

…ition to enable caching is on, tags will be stripped. Tests added. Fixes #1148
  • Loading branch information...
1 parent daeb23e commit 9cb15be76b11d4ebdd850d1811695fe1a1458800 @markstory markstory committed Sep 29, 2010
Showing with 34 additions and 4 deletions.
  1. +3 −3 cake/libs/view/view.php
  2. +31 −1 cake/tests/cases/libs/view/view.test.php
View
@@ -386,8 +386,8 @@ function render($action = null, $layout = null, $file = null) {
if ($layout && $this->autoLayout) {
$out = $this->renderLayout($out, $layout);
$isCached = (
- isset($this->loaded['cache']) &&
- (($this->cacheAction != false)) && (Configure::read('Cache.check') === true)
+ isset($this->loaded['cache']) ||
+ Configure::read('Cache.check') === true
);
if ($isCached) {
@@ -925,4 +925,4 @@ function renderElement($name, $params = array(), $loadHelpers = false) {
}
}
-?>
+?>
@@ -707,6 +707,36 @@ function testRenderCache() {
@unlink($path);
}
/**
+ * Test that render() will remove the cake:nocache tags when only the cachehelper is present.
+ *
+ * @return void
+ */
+ function testRenderStrippingNoCacheTagsOnlyCacheHelper() {
+ Configure::write('Cache.check', false);
+ $View =& new View($this->PostsController);
+ $View->set(array('superman' => 'clark', 'variable' => 'var'));
+ $View->helpers = array('Html', 'Form', 'Cache');
+ $View->layout = 'cache_layout';
+ $result = $View->render('index');
+ $this->assertNoPattern('/cake:nocache/', $result);
+ }
+
+/**
+ * Test that render() will remove the cake:nocache tags when only the Cache.check is true.
+ *
+ * @return void
+ */
+ function testRenderStrippingNoCacheTagsOnlyCacheCheck() {
+ Configure::write('Cache.check', true);
+ $View =& new View($this->PostsController);
+ $View->set(array('superman' => 'clark', 'variable' => 'var'));
+ $View->helpers = array('Html', 'Form');
+ $View->layout = 'cache_layout';
+ $result = $View->render('index');
+ $this->assertNoPattern('/cake:nocache/', $result);
+ }
+
+/**
* testRenderNocache method
*
* @access public
@@ -814,4 +844,4 @@ function testBadExt() {
$this->assertPattern("/<div id=\"content\">posts index<\/div>/", $result);
}
}
-?>
+?>

0 comments on commit 9cb15be

Please sign in to comment.