Fixing issue where plugin models in $uses, would create

incorrect forms when create() is called with no arguments.
Fixes #1841
This commit is contained in:
mark_story 2011-07-23 14:49:39 -04:00
parent 3589a17321
commit 6fb3c72d49
2 changed files with 3 additions and 5 deletions

View file

@ -866,7 +866,7 @@ class Controller extends Object {
if (!empty($this->uses)) { if (!empty($this->uses)) {
foreach ($this->uses as $model) { foreach ($this->uses as $model) {
list($plugin, $className) = pluginSplit($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())) { } if (!empty($this->modelClass) && ($this->uses === false || $this->uses === array())) {
$this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass); $this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass);

View file

@ -651,6 +651,7 @@ class ControllerTest extends CakeTestCase {
$Controller->view = null; $Controller->view = null;
$Controller = new TestController($request, new CakeResponse()); $Controller = new TestController($request, new CakeResponse());
$Controller->uses = array('ControllerAlias', 'TestPlugin.ControllerComment', 'ControllerPost');
$Controller->helpers = array('Html'); $Controller->helpers = array('Html');
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->ControllerComment->validationErrors = array('title' => 'tooShort'); $Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
@ -664,15 +665,12 @@ class ControllerTest extends CakeTestCase {
$expectedModels = array( $expectedModels = array(
'ControllerAlias' => array('plugin' => null, 'className' => 'ControllerAlias'), 'ControllerAlias' => array('plugin' => null, 'className' => 'ControllerAlias'),
'ControllerComment' => array('plugin' => null, 'className' => 'ControllerComment'), 'ControllerComment' => array('plugin' => 'TestPlugin', 'className' => 'ControllerComment'),
'ControllerPost' => array('plugin' => null, 'className' => 'ControllerPost') 'ControllerPost' => array('plugin' => null, 'className' => 'ControllerPost')
); );
$this->assertEqual($expectedModels, $Controller->request->params['models']); $this->assertEqual($expectedModels, $Controller->request->params['models']);
$Controller->ControllerComment->validationErrors = array();
ClassRegistry::flush(); ClassRegistry::flush();
App::build(); App::build();
} }