Don't return true from view classes' render() method.

It cause's Controller:render() to set the response body as `true`.

Refs #2780
This commit is contained in:
ADmad 2014-02-06 02:41:36 +05:30
parent 2cd72126fe
commit d9489257d3
4 changed files with 6 additions and 9 deletions

View file

@ -80,8 +80,7 @@ class MediaViewTest extends CakeTestCase {
$this->MediaView->response->expects($this->once())
->method('send');
$result = $this->MediaView->render();
$this->assertTrue($result);
$this->MediaView->render();
}
/**
@ -119,8 +118,7 @@ class MediaViewTest extends CakeTestCase {
$this->MediaView->response->expects($this->once())
->method('send');
$result = $this->MediaView->render();
$this->assertTrue($result);
$this->MediaView->render();
}
/**

View file

@ -1024,7 +1024,7 @@ class ViewTest extends CakeTestCase {
$this->assertRegExp("/<title>yo what up<\/title>/", $result);
$this->assertRegExp("/<p><a href=\"flash\">yo what up<\/a><\/p>/", $result);
$this->assertTrue($View->render(false, 'flash'));
$this->assertNull($View->render(false, 'flash'));
$this->PostsController->helpers = array('Session', 'Cache', 'Html');
$this->PostsController->constructClasses();

View file

@ -62,7 +62,7 @@ class MediaView extends View {
*
* @param string $view Not used
* @param string $layout Not used
* @return boolean
* @return void
*/
public function render($view = null, $layout = null) {
$name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null;
@ -94,7 +94,6 @@ class MediaView extends View {
$this->response->compress();
}
$this->response->send();
return true;
}
}

View file

@ -445,12 +445,12 @@ class View extends Object {
*
* @param string $view Name of view file to use
* @param string $layout Layout to use.
* @return string Rendered Element
* @return string|null Rendered content or null if content already rendered and returned earlier.
* @throws CakeException If there is an error in the view.
*/
public function render($view = null, $layout = null) {
if ($this->hasRendered) {
return true;
return;
}
$this->Blocks->set('content', '');