Permalink
Browse files

Removing old check for view == 'Theme'. This allows Scaffold to work …

…well with Themed controllers. Test case added. Fixes #255
  • Loading branch information...
1 parent 7e7a2c5 commit 3099a15f176bc206e1a0ba90a416b6f19baea528 @markstory markstory committed Aug 2, 2010
Showing with 21 additions and 2 deletions.
  1. +2 −2 cake/libs/controller/scaffold.php
  2. +19 −0 cake/tests/cases/libs/controller/scaffold.test.php
@@ -193,8 +193,8 @@ function __construct(&$controller, $params) {
'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations'
));
- if ($this->controller->view && $this->controller->view !== 'Theme') {
- $this->controller->view = 'scaffold';
+ if ($this->controller->view) {
@gBokiau
gBokiau Aug 28, 2011

FWIW, this check also seems unnecessary, since controller->view is always supposed to be set.

+ $this->controller->view = 'Scaffold';
}
$this->_validSession = (
isset($this->controller->Session) && $this->controller->Session->valid() != false
@@ -730,6 +730,7 @@ function testScaffoldParams() {
$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 @@ function testScaffoldVariableSetting() {
$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');
@lorenzo
lorenzo Aug 28, 2011 CakePHP member

Oops!

@markstory
markstory Aug 28, 2011 CakePHP member

Whoops, amazing that this lasted a year in the repo :( I fixed things up in [27ab909]

+ }
+
+/**
+ * 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.

0 comments on commit 3099a15

Please sign in to comment.