Removing old check for view == 'Theme'. This allows Scaffold to work well with Themed controllers. Test case added. Fixes #255

This commit is contained in:
mark_story 2010-08-01 22:25:29 -04:00
parent 7e7a2c57e2
commit 3099a15f17
2 changed files with 21 additions and 2 deletions

View file

@ -193,8 +193,8 @@ class Scaffold extends Object {
'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations'
));
if ($this->controller->view && $this->controller->view !== 'Theme') {
$this->controller->view = 'scaffold';
if ($this->controller->view) {
$this->controller->view = 'Scaffold';
}
$this->_validSession = (
isset($this->controller->Session) && $this->controller->Session->valid() != false

View file

@ -730,6 +730,7 @@ class ScaffoldTest extends CakeTestCase {
$result = $Scaffold->getParams();
$this->assertEqual($result['action'], 'admin_edit');
}
/**
* test that the proper names and variable values are set by Scaffold
*
@ -769,6 +770,24 @@ class ScaffoldTest extends CakeTestCase {
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
}
function getTests() {
return array('start', 'startCase', 'testScaffoldChangingViewProperty', 'endCase', 'end');
}
/**
* test that Scaffold overrides the view property even if its set to 'Theme'
*
* @return void
*/
function testScaffoldChangingViewProperty() {
$this->Controller->action = 'edit';
$this->Controller->theme = 'test_theme';
$this->Controller->view = 'Theme';
$this->Controller->constructClasses();
$Scaffold =& new TestScaffoldMock($this->Controller, array());
$this->assertEqual($this->Controller->view, 'Scaffold');
}
/**
* test that scaffold outputs flash messages when sessions are unset.