Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Merge branch '2.1' into 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 27, 2012
2 parents 1876b2f + 6bb8b22 commit 46bce1a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ protected function _scaffoldDelete(CakeRequest $request) {
throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass)));
}
if ($this->ScaffoldModel->delete()) {
$message = __d('cake', 'The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id);
$message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id);
return $this->_sendMessage($message);
} else {
$message = __d('cake',
'There was an error deleting the %1$s with id: %2$d',
'There was an error deleting the %1$s with id: %2$s',
Inflector::humanize($this->modelClass),
$id
);
Expand Down
7 changes: 5 additions & 2 deletions lib/Cake/Routing/Route/CakeRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,11 @@ public function match($url) {
* @return string Composed route string.
*/
protected function _writeUrl($params) {
if (isset($params['prefix'], $params['action'])) {
$params['action'] = str_replace($params['prefix'] . '_', '', $params['action']);
if (isset($params['prefix'])) {
$prefixed = $params['prefix'] . '_';
}
if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) {
$params['action'] = substr($params['action'], strlen($prefixed) * -1);
unset($params['prefix']);
}

Expand Down
7 changes: 4 additions & 3 deletions lib/Cake/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Router {
*
* @var string
*/
protected static $_routeClass = 'CakeRoute';
protected static $_routeClass = 'CakeRoute';

/**
* Set the default route class to use or return the current one
Expand Down Expand Up @@ -893,8 +893,9 @@ protected static function _handleNoRoute($url) {

list($args, $named) = array(Hash::filter($args), Hash::filter($named));
foreach (self::$_prefixes as $prefix) {
if (!empty($url[$prefix])) {
$url['action'] = str_replace($prefix . '_', '', $url['action']);
$prefixed = $prefix . '_';
if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) {
$url['action'] = substr($url['action'], strlen($prefixed) * -1);
break;
}
}
Expand Down
24 changes: 12 additions & 12 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3304,8 +3304,8 @@ public function testSaveAllDeepValidateOnly() {
$expected = array(
'Article' => true,
'Comment' => array(
true,
true
true,
true
)
);
$this->assertSame($expected, $result);
Expand All @@ -3323,8 +3323,8 @@ public function testSaveAllDeepValidateOnly() {
$expected = array(
'Article' => true,
'Comment' => array(
false,
true
false,
true
)
);
$this->assertSame($expected, $result);
Expand Down Expand Up @@ -3363,8 +3363,8 @@ public function testSaveAllDeepValidateOnly() {
$expected = array(
'Article' => true,
'Comment' => array(
true,
true
true,
true
)
);
$this->assertSame($expected, $result);
Expand All @@ -3381,8 +3381,8 @@ public function testSaveAllDeepValidateOnly() {
$expected = array(
'Article' => true,
'Comment' => array(
true,
false
true,
false
)
);
$this->assertSame($expected, $result);
Expand Down Expand Up @@ -3730,8 +3730,8 @@ public function testSaveAllNotDeepValidateOnly() {
$expected = array(
'Article' => true,
'Comment' => array(
true,
true
true,
true
)
);
$this->assertSame($expected, $result);
Expand Down Expand Up @@ -3759,8 +3759,8 @@ public function testSaveAllNotDeepValidateOnly() {
$expected = array(
'Article' => true,
'Comment' => array(
true,
true
true,
true
)
);
$this->assertSame($expected, $result);
Expand Down
10 changes: 10 additions & 0 deletions lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ public function testMatchBasic() {
$result = $route->match($url);
$expected = '/admin/subscriptions/edit/1';
$this->assertEquals($expected, $result);

$url = array(
'controller' => 'subscribe',
'admin' => true,
'action' => 'edit_admin_e',
1
);
$result = $route->match($url);
$expected = '/admin/subscriptions/edit_admin_e/1';
$this->assertEquals($expected, $result);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,10 @@ public function testUrlGenerationWithAutoPrefixes() {
$expected = '/protected/images/add';
$this->assertEquals($expected, $result);

$result = Router::url(array('controller' => 'images', 'action' => 'add_protected_test', 'protected' => true));
$expected = '/protected/images/add_protected_test';
$this->assertEquals($expected, $result);

$result = Router::url(array('action' => 'edit', 1));
$expected = '/images/edit/1';
$this->assertEquals($expected, $result);
Expand Down

0 comments on commit 46bce1a

Please sign in to comment.