summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-03 10:59:09 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-03 10:59:09 -0400
commitf87d3334e59cd2b57f97dedf2e60417fd1df9961 (patch)
tree46dc93afc7dfe0b3cbef0fb7620c3ab4de149508
parentd975a3ac45df8515a86ab656d1a48d85c9f83c27 (diff)
Take default swimlane into consideration for SwimlaneModel::getFirstActiveSwimlane()
-rw-r--r--ChangeLog1
-rw-r--r--app/Model/SwimlaneModel.php24
-rw-r--r--tests/units/Model/SwimlaneTest.php10
3 files changed, 24 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index c83ded02..1288534f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,7 @@ Bug fixes:
* Fixed lexer issue with non word characters
* Flush memory cache in worker to get latest config values
* Fixed empty title for web notification with only one overdue task
+* Take default swimlane into consideration for SwimlaneModel::getFirstActiveSwimlane()
Version 1.0.30
--------------
diff --git a/app/Model/SwimlaneModel.php b/app/Model/SwimlaneModel.php
index 35e39879..f20bfa2f 100644
--- a/app/Model/SwimlaneModel.php
+++ b/app/Model/SwimlaneModel.php
@@ -94,15 +94,17 @@ class SwimlaneModel extends Base
*
* @access public
* @param integer $project_id
- * @return array
+ * @return array|null
*/
public function getFirstActiveSwimlane($project_id)
{
- return $this->db->table(self::TABLE)
- ->eq('is_active', self::ACTIVE)
- ->eq('project_id', $project_id)
- ->orderBy('position', 'asc')
- ->findOne();
+ $swimlanes = $this->getSwimlanes($project_id);
+
+ if (empty($swimlanes)) {
+ return null;
+ }
+
+ return $swimlanes[0];
}
/**
@@ -184,18 +186,18 @@ class SwimlaneModel extends Base
->orderBy('position', 'asc')
->findAll();
- $default_swimlane = $this->db
+ $defaultSwimlane = $this->db
->table(ProjectModel::TABLE)
->eq('id', $project_id)
->eq('show_default_swimlane', 1)
->findOneColumn('default_swimlane');
- if ($default_swimlane) {
- if ($default_swimlane === 'Default swimlane') {
- $default_swimlane = t($default_swimlane);
+ if ($defaultSwimlane) {
+ if ($defaultSwimlane === 'Default swimlane') {
+ $defaultSwimlane = t($defaultSwimlane);
}
- array_unshift($swimlanes, array('id' => 0, 'name' => $default_swimlane));
+ array_unshift($swimlanes, array('id' => 0, 'name' => $defaultSwimlane));
}
return $swimlanes;
diff --git a/tests/units/Model/SwimlaneTest.php b/tests/units/Model/SwimlaneTest.php
index cf0be169..4541e07f 100644
--- a/tests/units/Model/SwimlaneTest.php
+++ b/tests/units/Model/SwimlaneTest.php
@@ -40,7 +40,17 @@ class SwimlaneTest extends Base
$this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
$swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
+ $this->assertEquals(0, $swimlane['id']);
+ $this->assertEquals('Default swimlane', $swimlane['name']);
+
+ $this->assertTrue($swimlaneModel->disableDefault(1));
+
+ $swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
$this->assertEquals(2, $swimlane['id']);
+ $this->assertEquals('Swimlane #2', $swimlane['name']);
+
+ $this->assertTrue($swimlaneModel->disable(1, 2));
+ $this->assertNull($swimlaneModel->getFirstActiveSwimlane(1));
}
public function testGetList()