Merge branch '2.1' into 2.2

This commit is contained in:
mark_story 2012-04-26 22:27:44 -04:00
commit 46bce1a00f
6 changed files with 37 additions and 19 deletions

View file

@ -305,11 +305,11 @@ class Scaffold {
throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass))); throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass)));
} }
if ($this->ScaffoldModel->delete()) { 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); return $this->_sendMessage($message);
} else { } else {
$message = __d('cake', $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), Inflector::humanize($this->modelClass),
$id $id
); );

View file

@ -478,8 +478,11 @@ class CakeRoute {
* @return string Composed route string. * @return string Composed route string.
*/ */
protected function _writeUrl($params) { protected function _writeUrl($params) {
if (isset($params['prefix'], $params['action'])) { if (isset($params['prefix'])) {
$params['action'] = str_replace($params['prefix'] . '_', '', $params['action']); $prefixed = $params['prefix'] . '_';
}
if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) {
$params['action'] = substr($params['action'], strlen($prefixed) * -1);
unset($params['prefix']); unset($params['prefix']);
} }

View file

@ -157,7 +157,7 @@ class Router {
* *
* @var string * @var string
*/ */
protected static $_routeClass = 'CakeRoute'; protected static $_routeClass = 'CakeRoute';
/** /**
* Set the default route class to use or return the current one * Set the default route class to use or return the current one
@ -893,8 +893,9 @@ class Router {
list($args, $named) = array(Hash::filter($args), Hash::filter($named)); list($args, $named) = array(Hash::filter($args), Hash::filter($named));
foreach (self::$_prefixes as $prefix) { foreach (self::$_prefixes as $prefix) {
if (!empty($url[$prefix])) { $prefixed = $prefix . '_';
$url['action'] = str_replace($prefix . '_', '', $url['action']); if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) {
$url['action'] = substr($url['action'], strlen($prefixed) * -1);
break; break;
} }
} }

View file

@ -3304,8 +3304,8 @@ class ModelWriteTest extends BaseModelTest {
$expected = array( $expected = array(
'Article' => true, 'Article' => true,
'Comment' => array( 'Comment' => array(
true, true,
true true
) )
); );
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
@ -3323,8 +3323,8 @@ class ModelWriteTest extends BaseModelTest {
$expected = array( $expected = array(
'Article' => true, 'Article' => true,
'Comment' => array( 'Comment' => array(
false, false,
true true
) )
); );
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
@ -3363,8 +3363,8 @@ class ModelWriteTest extends BaseModelTest {
$expected = array( $expected = array(
'Article' => true, 'Article' => true,
'Comment' => array( 'Comment' => array(
true, true,
true true
) )
); );
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
@ -3381,8 +3381,8 @@ class ModelWriteTest extends BaseModelTest {
$expected = array( $expected = array(
'Article' => true, 'Article' => true,
'Comment' => array( 'Comment' => array(
true, true,
false false
) )
); );
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
@ -3730,8 +3730,8 @@ class ModelWriteTest extends BaseModelTest {
$expected = array( $expected = array(
'Article' => true, 'Article' => true,
'Comment' => array( 'Comment' => array(
true, true,
true true
) )
); );
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
@ -3759,8 +3759,8 @@ class ModelWriteTest extends BaseModelTest {
$expected = array( $expected = array(
'Article' => true, 'Article' => true,
'Comment' => array( 'Comment' => array(
true, true,
true true
) )
); );
$this->assertSame($expected, $result); $this->assertSame($expected, $result);

View file

@ -299,6 +299,16 @@ class CakeRouteTest extends CakeTestCase {
$result = $route->match($url); $result = $route->match($url);
$expected = '/admin/subscriptions/edit/1'; $expected = '/admin/subscriptions/edit/1';
$this->assertEquals($expected, $result); $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);
} }
/** /**

View file

@ -1582,6 +1582,10 @@ class RouterTest extends CakeTestCase {
$expected = '/protected/images/add'; $expected = '/protected/images/add';
$this->assertEquals($expected, $result); $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)); $result = Router::url(array('action' => 'edit', 1));
$expected = '/images/edit/1'; $expected = '/images/edit/1';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);