Skip to content

Commit

Permalink
Fix issue where plugin prefixes would be included in generated view.
Browse files Browse the repository at this point in the history
Fix issue with `cake bake view Plugin.Model` style view creation.
Fixes #2095
  • Loading branch information
markstory committed Oct 13, 2011
1 parent 3c611ee commit 7f3c566
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Cake/Console/Command/Task/ViewTask.php
Expand Up @@ -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));
}
}
Expand Down
9 changes: 7 additions & 2 deletions lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php
Expand Up @@ -60,7 +60,7 @@ class ViewTaskComment extends Model {
*/
public $belongsTo = array(
'Article' => array(
'className' => 'ViewTaskArticle',
'className' => 'TestTest.ViewTaskArticle',
'foreignKey' => 'article_id'
)
);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7f3c566

Please sign in to comment.