diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 529c8b17c..12bcba1bd 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2702,11 +2702,13 @@ class Model extends Overloadable { if ($type === null) { if (Configure::read('Cache.check') === true) { $assoc[] = strtolower(Inflector::pluralize($this->alias)); + $assoc[] = strtolower(Inflector::underscore(Inflector::pluralize($this->alias))); foreach ($this->__associations as $key => $association) { foreach ($this->$association as $key => $className) { $check = strtolower(Inflector::pluralize($className['className'])); if (!in_array($check, $assoc)) { $assoc[] = strtolower(Inflector::pluralize($className['className'])); + $assoc[] = strtolower(Inflector::underscore(Inflector::pluralize($className['className']))); } } } diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 23277543c..be3fc9407 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -236,7 +236,7 @@ class CacheHelper extends AppHelper { if ($this->here == '/') { $path = 'home'; } - $cache = Inflector::slug($path); + $cache = strtolower(Inflector::slug($path)); if (empty($cache)) { return; diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 4bd9dbbb2..8e1853b73 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -2892,6 +2892,45 @@ class ModelTest extends CakeTestCase { ); $this->assertEqual($result['Monkey'], $expected); } + +/** + * test that Caches are getting cleared on save(). + * ensure that both inflections of controller names are getting cleared + * as url for controller could be either overallFavorites/index or overall_favorites/index + * + * @return void + **/ + function testCacheClearOnSave() { + $_back = array( + 'check' => Configure::read('Cache.check'), + 'disable' => Configure::read('Cache.disable'), + ); + Configure::write('Cache.check', true); + Configure::write('Cache.disable', false); + + $this->loadFixtures('OverallFavorite'); + $OverallFavorite =& new OverallFavorite(); + + touch(CACHE . 'views' . DS . 'some_dir_overallfavorites_index.php'); + touch(CACHE . 'views' . DS . 'some_dir_overall_favorites_index.php'); + + $data = array( + 'OverallFavorite' => array( + 'model_type' => '8-track', + 'model_id' => '3', + 'priority' => '1' + ) + ); + $OverallFavorite->create($data); + $OverallFavorite->save(); + + $this->assertFalse(file_exists(CACHE . 'views' . DS . 'some_dir_overallfavorites_index.php')); + $this->assertFalse(file_exists(CACHE . 'views' . DS . 'some_dir_overall_favorites_index.php')); + + Configure::write('Cache.check', $_back['check']); + Configure::write('Cache.disable', $_back['disable']); + } + /** * testSaveAll method * diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 04d39ba46..9b2f47724 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -105,7 +105,7 @@ class CacheHelperTest extends CakeTestCase { $this->assertNoPattern('/cake:nocache/', $result); $this->assertNoPattern('/php echo/', $result); - $filename = CACHE . 'views' . DS . 'cacheTest_cache_parsing.php'; + $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php'; $this->assertTrue(file_exists($filename)); $contents = file_get_contents($filename); @@ -131,7 +131,7 @@ class CacheHelperTest extends CakeTestCase { $this->assertNoPattern('/cake:nocache/', $result); $this->assertNoPattern('/php echo/', $result); - $filename = CACHE . 'views' . DS . 'cacheTest_cache_parsing.php'; + $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php'; $this->assertTrue(file_exists($filename)); $contents = file_get_contents($filename); @@ -175,7 +175,7 @@ class CacheHelperTest extends CakeTestCase { //$this->assertNoPattern('/6\. in element with no cache tags/', $result); $this->assertNoPattern('/7\. layout after content and after element with no cache tags/', $result); - $filename = CACHE . 'views' . DS . 'cacheTest_cache_complex.php'; + $filename = CACHE . 'views' . DS . 'cachetest_cache_complex.php'; $this->assertTrue(file_exists($filename)); $contents = file_get_contents($filename); @unlink($filename); @@ -220,7 +220,7 @@ class CacheHelperTest extends CakeTestCase { 'cached count is: 3\s*' . '@', $result); - $filename = CACHE . 'views' . DS . 'cacheTest_cache_empty_sections.php'; + $filename = CACHE . 'views' . DS . 'cachetest_cache_empty_sections.php'; $this->assertTrue(file_exists($filename)); $contents = file_get_contents($filename); $this->assertNoPattern('/cake:nocache/', $contents);