Merge branch 'master' into 2.4

Conflicts:
	lib/Cake/VERSION.txt
This commit is contained in:
mark_story 2013-04-28 17:00:30 -04:00
commit 62186ac8da
4 changed files with 39 additions and 11 deletions

View file

@ -372,6 +372,7 @@ class PaginatorComponent extends Component {
$field = key($options['order']);
if (!in_array($field, $whitelist)) {
$options['order'] = null;
return $options;
}
}
@ -385,7 +386,7 @@ class PaginatorComponent extends Component {
}
if ($object->hasField($field)) {
$order[$alias . '.' . $field] = $value;
$order[$object->alias . '.' . $field] = $value;
} elseif ($object->hasField($key, true)) {
$order[$field] = $value;
} elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field, true)) {

View file

@ -969,10 +969,12 @@ class PaginatorComponentTest extends CakeTestCase {
$model->alias = 'model';
$model->expects($this->any())->method('hasField')->will($this->returnValue(true));
$options = array('order' => array(
'author_id' => 'asc',
'title' => 'asc'
));
$options = array(
'order' => array(
'author_id' => 'asc',
'title' => 'asc'
)
);
$result = $this->Paginator->validateSort($model, $options);
$expected = array(
'model.author_id' => 'asc',
@ -1002,6 +1004,21 @@ class PaginatorComponentTest extends CakeTestCase {
$this->assertEquals($options['order'], $result['order']);
}
/**
* Test sorting with incorrect aliases on valid fields.
*
* @return void
*/
public function testValidateSortInvalidAlias() {
$model = $this->getMock('Model');
$model->alias = 'Model';
$model->expects($this->any())->method('hasField')->will($this->returnValue(true));
$options = array('sort' => 'Derp.id');
$result = $this->Paginator->validateSort($model, $options);
$this->assertEquals(array('Model.id' => 'asc'), $result['order']);
}
/**
* test that maxLimit is respected
*

View file

@ -658,6 +658,21 @@ class HelperTest extends CakeTestCase {
$this->assertEquals('foo.jpg?one=two&three=four', $result);
}
/**
* Test assetUrl with no rewriting.
*
* @return void
*/
public function testAssetUrlNoRewrite() {
$this->Helper->request->addPaths(array(
'base' => '/cake_dev/index.php',
'webroot' => '/cake_dev/app/webroot/',
'here' => '/cake_dev/index.php/tasks',
));
$result = $this->Helper->assetUrl('img/cake.icon.png', array('fullBase' => true));
$this->assertEquals('http://localhost/cake_dev/app/webroot/img/cake.icon.png', $result);
}
/**
* Test assetUrl with plugins.
*

View file

@ -328,12 +328,7 @@ class Helper extends Object {
$path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
if (!empty($options['fullBase'])) {
$base = $this->url('/', true);
$len = strlen($this->request->webroot);
if ($len) {
$base = substr($base, 0, -$len);
}
$path = $base . $path;
$path = rtrim(FULL_BASE_URL, '/') . '/' . ltrim($path, '/');
}
return $path;
}