diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index 2ebffc733..7ccc74072 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -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); diff --git a/cake/tests/cases/console/libs/tasks/view.test.php b/cake/tests/cases/console/libs/tasks/view.test.php index 12f9d79d7..405b00a9a 100644 --- a/cake/tests/cases/console/libs/tasks/view.test.php +++ b/cake/tests/cases/console/libs/tasks/view.test.php @@ -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 *