diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 68eef867dd4..efc574aa4cc 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -449,10 +449,11 @@ protected function _associations($model) { foreach ($keys as $key => $type) { foreach ($model->{$type} as $assocKey => $assocData) { + list($plugin, $modelClass) = pluginSplit($assocData['className']); $associations[$type][$assocKey]['primaryKey'] = $model->{$assocKey}->primaryKey; $associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField; $associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey']; - $associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($assocData['className'])); + $associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($modelClass)); $associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema(true)); } } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 861e936fd96..ef6d61746d7 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -60,7 +60,7 @@ class ViewTaskComment extends Model { */ public $belongsTo = array( 'Article' => array( - 'className' => 'ViewTaskArticle', + 'className' => 'TestTest.ViewTaskArticle', 'foreignKey' => 'article_id' ) ); @@ -385,7 +385,12 @@ public function testBakeWithPlugin() { //fake plugin path CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS)); $path = APP . 'Plugin' . DS . 'TestTest' . DS . 'View' . DS . 'ViewTaskComments' . DS . 'view.ctp'; - $this->Task->expects($this->once())->method('createFile') + + $result = $this->Task->getContent('index'); + $this->assertNotContains('List Test Test.view Task Articles', $result); + + $this->Task->expects($this->once()) + ->method('createFile') ->with($path, $this->anything()); $this->Task->bake('view', true);