Skip to content
Permalink
Browse files

Adding property to signal which actions to skip finding templates for.

…Fixes #330
  • Loading branch information...
markstory committed Feb 13, 2010
1 parent 2e8e233 commit 5f5aae71e77e9c147a995afb90439f1c723eeb24
Showing with 38 additions and 6 deletions.
  1. +15 −4 cake/console/libs/tasks/view.php
  2. +23 −2 cake/tests/cases/console/libs/tasks/view.test.php
@@ -83,6 +83,15 @@ class ViewTask extends Shell {
*/
var $scaffoldActions = array('index', 'view', 'add', 'edit');
/**
* An array of action names that don't require templates. These
* actions will not emit errors when doing bakeActions()
*
* @var array
* @access public
*/
var $noTemplateActions = array('delete');
/**
* Override initialize
*
@@ -381,10 +390,9 @@ function getContent($action, $vars = null) {
$this->Template->set('action', $action);
$this->Template->set('plugin', $this->plugin);
$this->Template->set($vars);
$output = $this->Template->generate('views', $this->getTemplate($action));
if (!empty($output)) {
return $output;
$template = $this->getTemplate($action);
if ($template) {
return $this->Template->generate('views', $template);
}
return false;
}
@@ -397,6 +405,9 @@ function getContent($action, $vars = null) {
* @access public
*/
function getTemplate($action) {
if ($action != $this->template && in_array($action, $this->noTemplateActions)) {
return false;
}
if (!empty($this->template) && $action != $this->template) {
return $this->template;
}
@@ -113,7 +113,7 @@ class ViewTaskArticle extends Model {
}
/**
* Test View Task Comments Controller
* Test View Task Comments Controller
*
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
@@ -261,6 +261,8 @@ function startTest() {
$this->Task->Project =& new ViewTaskMockProjectTask();
$this->Task->path = TMP;
$this->Task->Template->params['theme'] = 'default';
$this->_routing = Configure::read('Routing');
}
/**
@@ -271,6 +273,7 @@ function startTest() {
*/
function endTest() {
ClassRegistry::flush();
Configure::write('Routing', $this->_routing);
}
/**
@@ -554,7 +557,7 @@ function testExecuteWithAlternateTemplates() {
$this->Task->connection = 'test_suite';
$this->Task->args = array('ViewTaskComments', 'index', 'list');
$this->Task->params = array();
$this->Task->expectCallCount('createFile', 1);
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'list.ctp',
@@ -600,5 +603,23 @@ function testExecuteInteractiveWithAdmin() {
$this->Task->execute();
}
/**
* test getting templates, make sure noTemplateActions works
*
* @return void
*/
function testGetTemplate() {
$result = $this->Task->getTemplate('delete');
$this->assertFalse($result);
$result = $this->Task->getTemplate('add');
$this->assertEqual($result, 'form');
Configure::write('Routing.prefixes', array('admin'));
$result = $this->Task->getTemplate('admin_add');
$this->assertEqual($result, 'form');
}
}
?>

0 comments on commit 5f5aae7

Please sign in to comment.
You can’t perform that action at this time.