diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 7eeeb8438..6ead64246 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -122,7 +122,7 @@ class JsHelper extends AppHelper { * * - 'inline' - Set to true to have scripts output as a script block inline * if 'cache' is also true, a script link tag will be generated. (default true) - * - 'cache' - Set to true to have scripts cached to a file and linked in (default true) + * - 'cache' - Set to true to have scripts cached to a file and linked in (default false) * - 'clear' - Set to false to prevent script cache from being cleared (default true) * - 'onDomReady' - wrap cached scripts in domready event (default true) * - 'safe' - if an inline block is generated should it be wrapped in (default true) @@ -131,7 +131,7 @@ class JsHelper extends AppHelper { * @return string completed javascript tag. **/ function writeScripts($options = array()) { - $defaults = array('onDomReady' => true, 'inline' => true, 'cache' => true, 'clear' => true, 'safe' => true); + $defaults = array('onDomReady' => true, 'inline' => true, 'cache' => false, 'clear' => true, 'safe' => true); $options = array_merge($defaults, $options); $script = implode("\n", $this->getCache($options['clear'])); diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index e70ef652d..667fdb218 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -171,7 +171,7 @@ class JsHelperTestCase extends CakeTestCase { $this->Js->JsBaseEngine = new TestJsEngineHelper(); $this->Js->writeCache('one = 1;'); $this->Js->writeCache('two = 2;'); - $result = $this->Js->writeScripts(array('onDomReady' => false)); + $result = $this->Js->writeScripts(array('onDomReady' => false, 'cache' => true)); $expected = array( 'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'), ); @@ -180,6 +180,8 @@ class JsHelperTestCase extends CakeTestCase { $this->assertTrue(file_exists(WWW_ROOT . $filename[1])); $contents = file_get_contents(WWW_ROOT . $filename[1]); $this->assertPattern('/one\s=\s1;\ntwo\s=\s2;/', $contents); + + @unlink(WWW_ROOT . $filename[1]); } }