Permalink
Browse files

Fixing issue where ViewTask would make empty view files for actions t…

…hat did not have templates. Test case added. Fixes #1040
  • Loading branch information...
markstory committed Aug 24, 2010
1 parent ece055e commit c48c0d62950d28e0c0cb01cfb25bef3b21cc0529
Showing with 16 additions and 0 deletions.
  1. +3 −0 cake/console/libs/tasks/view.php
  2. +13 −0 cake/tests/cases/console/libs/tasks/view.test.php
@@ -366,6 +366,9 @@ function bake($action, $content = '') {
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);
@@ -374,6 +374,19 @@ function testBake() {
$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
*

0 comments on commit c48c0d6

Please sign in to comment.