Fixing double merging of url options in paginator helper. This was causing duplicate passed url parameters in next()/prev().

Test cases added.
Fixes #391
This commit is contained in:
Mark Story 2009-12-08 09:58:45 -05:00
parent c64389006d
commit efa36abdf0
2 changed files with 22 additions and 3 deletions

View file

@ -411,12 +411,12 @@ class PaginatorHelper extends AppHelper {
${$key} = $options[$key];
unset($options[$key]);
}
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
$urlParams = array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step));
if ($this->{$check}($model)) {
return $this->link($title, $url, array_merge($options, array('escape' => $escape, 'class' => $class)));
return $this->link($title, $urlParams, array_merge($options, compact('escape', 'class', 'url')));
} else {
return $this->Html->tag($tag, $title, array_merge($options, array('class' => $class, 'escape' => $escape)));
return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
}
}

View file

@ -745,6 +745,25 @@ class PaginatorHelperTest extends CakeTestCase {
'/a',
);
$this->assertTags($result, $expected);
$this->Paginator->params['paging'] = array(
'Client' => array(
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true,
'nextPage' => false, 'pageCount' => 2,
'defaults' => array(),
'options' => array(
'page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array()
)
)
);
$this->Paginator->options(array('url' => array(12, 'page' => 3)));
$result = $this->Paginator->prev('Prev', array('url' => array(12, 'foo' => 'bar')));
$expected = array(
'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'),
'Prev',
'/a',
);
$this->assertTags($result, $expected);
}
/**