Permalink
Browse files

Merge pull request #650 from yitznewton/dev

From Controller, look for view in own library
  • Loading branch information...
2 parents d35f656 + a29012a commit 1d6fae0c3512365851177d5cd86535dfc097d1f7 @nateabele nateabele committed Sep 21, 2012
Showing with 20 additions and 1 deletion.
  1. +4 −1 action/Controller.php
  2. +16 −0 tests/cases/action/ControllerTest.php
View
@@ -10,6 +10,7 @@
use lithium\util\Inflector;
use lithium\action\DispatchException;
+use lithium\core\Libraries;
/**
* The `Controller` class is the fundamental building block of your application's request/response
@@ -243,8 +244,10 @@ public function render(array $options = array()) {
'location' => false,
'data' => null,
'head' => false,
- 'controller' => Inflector::underscore($name)
+ 'controller' => Inflector::underscore($name),
+ 'library' => Libraries::get($class)
);
+
$options += $this->_render + $defaults;
if ($key && $media::type($key)) {
@@ -372,6 +372,22 @@ public function testNonExistentFunction() {
$this->expectException("Action `foo` not found.");
$postsController(new Request(), array('action' => 'foo'));
}
+
+ /**
+ * Tests that the library of the controller is automatically added to the default rendering
+ * options.
+ */
+ public function testLibraryScoping() {
+ $request = new Request();
+ $request->params['controller'] = 'lithium\tests\mocks\action\MockPostsController';
+
+ $controller = new MockPostsController(compact('request') + array('classes' => array(
+ 'media' => 'lithium\tests\mocks\action\MockMediaClass'
+ )));
+
+ $controller->render();
+ $this->assertEqual('lithium', $controller->response->options['library']);
+ }
}
?>

0 comments on commit 1d6fae0

Please sign in to comment.