summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/models/mmultipaste.php2
-rw-r--r--application/test/tests/test_api_v2.php29
2 files changed, 30 insertions, 1 deletions
diff --git a/application/models/mmultipaste.php b/application/models/mmultipaste.php
index fc0889377..52ea4dfb4 100644
--- a/application/models/mmultipaste.php
+++ b/application/models/mmultipaste.php
@@ -125,7 +125,7 @@ class Mmultipaste extends CI_Model {
$f = new \service\storage($this->get_tarball_path($id));
$f->unlink();
- return $this->id_exists($id);
+ return !$this->id_exists($id);
}
public function get_owner($id)
diff --git a/application/test/tests/test_api_v2.php b/application/test/tests/test_api_v2.php
index 7335c3bdd..0e52de50b 100644
--- a/application/test/tests/test_api_v2.php
+++ b/application/test/tests/test_api_v2.php
@@ -494,4 +494,33 @@ class test_api_v2 extends \test\Test {
),
), $ret, "expected error response");
}
+
+ public function test_delete_canDeleteMultipaste()
+ {
+ $apikey = $this->createUserAndApikey();
+ $ret = $this->uploadFile($apikey, "data/tests/small-file");
+ $id = $ret["data"]["ids"][0];
+ $ret = $this->CallEndpoint("POST", "file/create_multipaste", array(
+ "apikey" => $apikey,
+ "ids[1]" => $id,
+ ));
+ $this->expectSuccess("create multipaste", $ret);
+
+ $mid = $ret['data']['url_id'];
+ $ret = $this->CallEndpoint("POST", "file/delete", array(
+ "apikey" => $apikey,
+ "ids[1]" => $mid,
+ ));
+ $this->expectSuccess("delete uploaded file", $ret);
+
+ $this->t->ok(empty($ret["data"]["errors"]), "no errors");
+ $this->t->is_deeply(array(
+ $mid => array(
+ "id" => $mid
+ )
+ ), $ret["data"]["deleted"], "deleted wanted ID");
+ $this->t->is($ret["data"]["total_count"], 1, "total_count correct");
+ $this->t->is($ret["data"]["deleted_count"], 1, "deleted_count correct");
+ }
+
}