Skip to content
Permalink
Browse files

Ensure callbacks are triggered when using Xml/Json view with view tem…

…plates.

PaginatorHelper for instance needs this to correctly set options
  • Loading branch information...
ceeram committed Aug 22, 2012
1 parent 62dd391 commit e7dc23b920ac1b1b4825d57538a12c395939ba20
@@ -76,6 +76,7 @@ public function testRenderWithView() {
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$Request = new CakeRequest();
$Request->params['named'] = array('page' => 2);
$Response = new CakeResponse();
$Controller = new Controller($Request, $Response);
$Controller->name = $Controller->viewPath = 'Posts';
@@ -91,9 +92,10 @@ public function testRenderWithView() {
);
$Controller->set('user', $data);
$View = new JsonView($Controller);
$View->helpers = array('Paginator');
$output = $View->render('index');
$expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2')));
$expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2'), 'paging' => array('page' => 2)));
$this->assertSame($expected, $output);
$this->assertSame('application/json', $Response->type());
}
@@ -16,9 +16,12 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
$paging = isset($this->Paginator->options['url']) ? $this->Paginator->options['url'] : null;
$formatted = array(
'user' => $user['User']['username'],
'list' => array()
'list' => array(),
'paging' => $paging,
);
foreach ($user['Item'] as $item) {
$formatted['list'][] = $item['name'];
@@ -85,12 +85,7 @@ public function render($view = null, $layout = null) {
return $this->_serialize($this->viewVars['_serialize']);
}
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
if (!$this->_helpersLoaded) {
$this->loadHelpers();
}
$content = $this->_render($viewFileName);
$this->Blocks->set('content', $content);
return $content;
return parent::render($view, false);
}
}
@@ -88,12 +88,7 @@ public function render($view = null, $layout = null) {
return $this->_serialize($this->viewVars['_serialize']);
}
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
if (!$this->_helpersLoaded) {
$this->loadHelpers();
}
$content = $this->_render($viewFileName);
$this->Blocks->set('content', (string)$content);
return $content;
return parent::render($view, false);
}
}

0 comments on commit e7dc23b

Please sign in to comment.
You can’t perform that action at this time.