summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Integration/GithubWebhook.php14
-rw-r--r--app/Integration/GitlabWebhook.php2
-rw-r--r--app/Model/TaskFinder.php5
-rw-r--r--tests/units/GitlabWebhookTest.php5
4 files changed, 15 insertions, 11 deletions
diff --git a/app/Integration/GithubWebhook.php b/app/Integration/GithubWebhook.php
index 121fdd1b..0070c309 100644
--- a/app/Integration/GithubWebhook.php
+++ b/app/Integration/GithubWebhook.php
@@ -139,7 +139,7 @@ class GithubWebhook extends Base
*/
public function parseCommentIssueEvent(array $payload)
{
- $task = $this->taskFinder->getByReference($payload['issue']['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $payload['issue']['number']);
$user = $this->user->getByUsername($payload['comment']['user']['login']);
if (! empty($task) && ! empty($user)) {
@@ -196,7 +196,7 @@ class GithubWebhook extends Base
*/
public function handleIssueClosed(array $issue)
{
- $task = $this->taskFinder->getByReference($issue['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
if (! empty($task)) {
$event = array(
@@ -225,7 +225,7 @@ class GithubWebhook extends Base
*/
public function handleIssueReopened(array $issue)
{
- $task = $this->taskFinder->getByReference($issue['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
if (! empty($task)) {
$event = array(
@@ -255,7 +255,7 @@ class GithubWebhook extends Base
public function handleIssueAssigned(array $issue)
{
$user = $this->user->getByUsername($issue['assignee']['login']);
- $task = $this->taskFinder->getByReference($issue['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
if (! empty($user) && ! empty($task)) {
@@ -286,7 +286,7 @@ class GithubWebhook extends Base
*/
public function handleIssueUnassigned(array $issue)
{
- $task = $this->taskFinder->getByReference($issue['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
if (! empty($task)) {
@@ -318,7 +318,7 @@ class GithubWebhook extends Base
*/
public function handleIssueLabeled(array $issue, array $label)
{
- $task = $this->taskFinder->getByReference($issue['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
if (! empty($task)) {
@@ -350,7 +350,7 @@ class GithubWebhook extends Base
*/
public function handleIssueUnlabeled(array $issue, array $label)
{
- $task = $this->taskFinder->getByReference($issue['number']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['number']);
if (! empty($task)) {
diff --git a/app/Integration/GitlabWebhook.php b/app/Integration/GitlabWebhook.php
index dbba3663..e30a0b50 100644
--- a/app/Integration/GitlabWebhook.php
+++ b/app/Integration/GitlabWebhook.php
@@ -191,7 +191,7 @@ class GitlabWebhook extends Base
*/
public function handleIssueClosed(array $issue)
{
- $task = $this->taskFinder->getByReference($issue['id']);
+ $task = $this->taskFinder->getByReference($this->project_id, $issue['id']);
if (! empty($task)) {
$event = array(
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 7216e92a..54dd578a 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -204,12 +204,13 @@ class TaskFinder extends Base
* Fetch a task by the reference (external id)
*
* @access public
+ * @param integer $project_id Project id
* @param string $reference Task reference
* @return array
*/
- public function getByReference($reference)
+ public function getByReference($project_id, $reference)
{
- return $this->db->table(Task::TABLE)->eq('reference', $reference)->findOne();
+ return $this->db->table(Task::TABLE)->eq('project_id', $project_id)->eq('reference', $reference)->findOne();
}
/**
diff --git a/tests/units/GitlabWebhookTest.php b/tests/units/GitlabWebhookTest.php
index 0f2a5c12..cea4e839 100644
--- a/tests/units/GitlabWebhookTest.php
+++ b/tests/units/GitlabWebhookTest.php
@@ -88,9 +88,12 @@ class GitlabWebhookTest extends Base
// Create a task with the issue reference
$this->assertEquals(1, $tc->create(array('title' => 'A', 'project_id' => 1, 'reference' => 103361)));
- $task = $tf->getByReference(103361);
+ $task = $tf->getByReference(1, 103361);
$this->assertNotEmpty($task);
+ $task = $tf->getByReference(2, 103361);
+ $this->assertEmpty($task);
+
$this->assertTrue($g->handleIssueClosed($event['object_attributes']));
$called = $this->container['dispatcher']->getCalledListeners();