Skip to content

Commit

Permalink
Fixing issue where ViewTask would make empty view files for actions t…
Browse files Browse the repository at this point in the history
…hat did not have templates. Test case added. Fixes #1040
  • Loading branch information
markstory committed Aug 24, 2010
1 parent ece055e commit c48c0d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cake/console/libs/tasks/view.php
Expand Up @@ -366,6 +366,9 @@ function bake($action, $content = '') {
if ($content === true) { if ($content === true) {
$content = $this->getContent($action); $content = $this->getContent($action);
} }
if (empty($content)) {
return false;
}
$path = $this->getPath(); $path = $this->getPath();
$filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp'; $filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
return $this->createFile($filename, $content); return $this->createFile($filename, $content);
Expand Down
13 changes: 13 additions & 0 deletions cake/tests/cases/console/libs/tasks/view.test.php
Expand Up @@ -374,6 +374,19 @@ function testBake() {
$this->Task->bake('index', true); $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 * test bake() with a -plugin param
* *
Expand Down

0 comments on commit c48c0d6

Please sign in to comment.