Disabling caching of JS files by default. Requiring webroot to be

writable by default it not a good idea.
This commit is contained in:
mark_story 2009-03-19 22:05:06 -04:00
parent 0bd3cc97c1
commit f15b793a4a
2 changed files with 5 additions and 3 deletions

View file

@ -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 <![CDATA[ ... ]]> (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']));

View file

@ -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]);
}
}