Skip to content

Commit

Permalink
Making PluginShortRoute check that the action exists before attemptin…
Browse files Browse the repository at this point in the history
…g to proceed. Updated tests.
  • Loading branch information
markstory committed Apr 3, 2010
1 parent a18d1be commit 9580217
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cake/libs/router.php
Expand Up @@ -1631,6 +1631,9 @@ function parse($url) {
if (!App::import('Controller', $controllerName)) {
return false;
}
if (!method_exists($pluginName . 'Controller', $params['action'])) {
return false;
}
$params['controller'] = $params['plugin'];
return $params;
}
Expand Down
4 changes: 2 additions & 2 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -2497,10 +2497,10 @@ function testParsing() {
$this->assertEqual($result['controller'], 'test_plugin');
$this->assertEqual($result['action'], 'add');

$result = $route->parse('/test_plugin/edit/1');
$result = $route->parse('/test_plugin/add/1');
$this->assertEqual($result['plugin'], 'test_plugin');
$this->assertEqual($result['controller'], 'test_plugin');
$this->assertEqual($result['action'], 'edit');
$this->assertEqual($result['action'], 'add');
$this->assertEqual($result['_args_'], '1', 'Passed args were wrong.');
}
}
Expand Down

0 comments on commit 9580217

Please sign in to comment.