Fixing issue where ViewTask would make empty view files for actions that did not have templates. Test case added. Fixes #1040

This commit is contained in:
mark_story 2010-08-23 21:49:30 -04:00
parent ece055eefe
commit c48c0d6295
2 changed files with 16 additions and 0 deletions

View file

@ -366,6 +366,9 @@ class ViewTask extends BakeTask {
if ($content === true) {
$content = $this->getContent($action);
}
if (empty($content)) {
return false;
}
$path = $this->getPath();
$filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
return $this->createFile($filename, $content);

View file

@ -374,6 +374,19 @@ class ViewTaskTest extends CakeTestCase {
$this->Task->bake('index', true);
}
/**
* test that baking a view with no template doesn't make a file.
*
* @return void
*/
function testBakeWithNoTemplate() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->expectNever('createFile');
$this->Task->bake('delete', true);
}
/**
* test bake() with a -plugin param
*