Permalink
Browse files

Fixing issue where plugin models in $uses, would create

incorrect forms when create() is called with no arguments.
Fixes #1841
  • Loading branch information...
1 parent 3589a17 commit 6fb3c72d490c23bfa98676c0bfce37c05d02a10f @markstory markstory committed Jul 23, 2011
Showing with 3 additions and 5 deletions.
  1. +1 −1 lib/Cake/Controller/Controller.php
  2. +2 −4 lib/Cake/Test/Case/Controller/ControllerTest.php
@@ -866,7 +866,7 @@ public function render($view = null, $layout = null) {
if (!empty($this->uses)) {
foreach ($this->uses as $model) {
list($plugin, $className) = pluginSplit($model);
- $this->request->params['models'][$model] = compact('plugin', 'className');
+ $this->request->params['models'][$className] = compact('plugin', 'className');
}
} if (!empty($this->modelClass) && ($this->uses === false || $this->uses === array())) {
$this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass);
@@ -651,6 +651,7 @@ public function testRender() {
$Controller->view = null;
$Controller = new TestController($request, new CakeResponse());
+ $Controller->uses = array('ControllerAlias', 'TestPlugin.ControllerComment', 'ControllerPost');
$Controller->helpers = array('Html');
$Controller->constructClasses();
$Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
@@ -664,15 +665,12 @@ public function testRender() {
$expectedModels = array(
'ControllerAlias' => array('plugin' => null, 'className' => 'ControllerAlias'),
- 'ControllerComment' => array('plugin' => null, 'className' => 'ControllerComment'),
+ 'ControllerComment' => array('plugin' => 'TestPlugin', 'className' => 'ControllerComment'),
'ControllerPost' => array('plugin' => null, 'className' => 'ControllerPost')
);
$this->assertEqual($expectedModels, $Controller->request->params['models']);
-
- $Controller->ControllerComment->validationErrors = array();
ClassRegistry::flush();
-
App::build();
}

0 comments on commit 6fb3c72

Please sign in to comment.