diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 7939aa910b5..89d5ae5d572 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -680,7 +680,7 @@ protected function _getViewFileName($name = null) { } if ($name === null) { - $name = $this->action; + $name = $this->view; } $name = str_replace('/', DS, $name); diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 2b6417e5a55..74058c3dbf3 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -701,6 +701,20 @@ function testRender() { $this->assertPattern("/
posts index<\/div>/", $result); } +/** + * test that View::$view works + * + * @return void + */ + function testRenderUsingViewProperty() { + $this->PostsController->view = 'cache_form'; + $View = new TestView($this->PostsController); + + $this->assertEquals('cache_form', $View->view); + $result = $View->render(); + $this->assertRegExp('/Add User/', $result); + } + /** * test that view vars can replace the local helper variables * and not overwrite the $this->Helper references