Make sure there is always a trailing slash for application_url

This commit is contained in:
Frederic Guillot 2015-09-30 22:21:35 -04:00
parent 8970fba41f
commit 792d5a20bc
3 changed files with 20 additions and 7 deletions

View File

@ -18,6 +18,7 @@ Core functionalities moved to plugins:
Improvements:
* Make sure there is always a trailing slash for application_url
* Do not show the checkbox "Show default swimlane" when there is no active swimlanes
* Append filters instead of replacing value for users and categories dropdowns
* Do not show empty swimlanes in public view

View File

@ -208,6 +208,11 @@ class Config extends Base
{
foreach ($values as $option => $value) {
// Be sure that a trailing slash is there for the url
if ($option === 'application_url' && ! empty($value) && substr($value, -1) !== '/') {
$value .= '/';
}
$result = $this->db->table(self::TABLE)->eq('option', $option)->update(array('value' => $value));
if (! $result) {

View File

@ -7,6 +7,20 @@ use Core\Session;
class ConfigTest extends Base
{
public function testSaveApplicationUrl()
{
$c = new Config($this->container);
$this->assertTrue($c->save(array('application_url' => 'http://localhost/')));
$this->assertEquals('http://localhost/', $c->get('application_url'));
$this->assertTrue($c->save(array('application_url' => 'http://localhost')));
$this->assertEquals('http://localhost/', $c->get('application_url'));
$this->assertTrue($c->save(array('application_url' => '')));
$this->assertEquals('', $c->get('application_url'));
}
public function testDefaultValues()
{
$c = new Config($this->container);
@ -56,11 +70,4 @@ class ConfigTest extends Base
session_id('');
unset($this->container['session']);
}
public function testSave()
{
$c = new Config($this->container);
$this->assertTrue($c->save(array('application_url' => 'http://localhost/')));
$this->assertEquals('http://localhost/', $c->get('application_url'));
}
}