|
@@ -139,6 +139,7 @@ class HookHandleTest(TestCase):
|
|
|
"user": {"email": user.email},
|
|
|
"slug": {"commit": "abcd123"},
|
|
|
"app": {"name": "example"},
|
|
|
+ "action": "update",
|
|
|
}
|
|
|
}
|
|
|
req.body = bytes(json.dumps(body), "utf-8")
|
|
@@ -146,6 +147,28 @@ class HookHandleTest(TestCase):
|
|
|
assert Release.objects.filter(version=body["data"]["slug"]["commit"]).exists()
|
|
|
assert hook.set_refs.call_count == 1
|
|
|
|
|
|
+ def test_only_run_on_update(self):
|
|
|
+ user = self.create_user()
|
|
|
+ organization = self.create_organization(owner=user)
|
|
|
+ project = self.create_project(organization=organization)
|
|
|
+ hook = HerokuReleaseHook(project)
|
|
|
+ hook.is_valid_signature = Mock()
|
|
|
+ hook.set_refs = Mock()
|
|
|
+
|
|
|
+ req = Mock()
|
|
|
+ body = {
|
|
|
+ "data": {
|
|
|
+ "user": {"email": user.email},
|
|
|
+ "slug": {"commit": "abcd123"},
|
|
|
+ "app": {"name": "example"},
|
|
|
+ "action": "create",
|
|
|
+ }
|
|
|
+ }
|
|
|
+ req.body = bytes(json.dumps(body), "utf-8")
|
|
|
+ hook.handle(req)
|
|
|
+ assert not Release.objects.filter(version=body["data"]["slug"]["commit"]).exists()
|
|
|
+ assert hook.set_refs.call_count == 0
|
|
|
+
|
|
|
def test_actor_email_success(self):
|
|
|
user = self.create_user()
|
|
|
organization = self.create_organization(owner=user)
|
|
@@ -160,6 +183,7 @@ class HookHandleTest(TestCase):
|
|
|
"actor": {"email": user.email},
|
|
|
"slug": {"commit": "abcd123"},
|
|
|
"app": {"name": "example"},
|
|
|
+ "action": "update",
|
|
|
}
|
|
|
}
|
|
|
req.body = bytes(json.dumps(body), "utf-8")
|
|
@@ -180,6 +204,7 @@ class HookHandleTest(TestCase):
|
|
|
"user": {"email": "wrong@example.com"},
|
|
|
"slug": {"commit": "v999"},
|
|
|
"app": {"name": "example"},
|
|
|
+ "action": "update",
|
|
|
}
|
|
|
}
|
|
|
req.body = bytes(json.dumps(body), "utf-8")
|
|
@@ -198,6 +223,7 @@ class HookHandleTest(TestCase):
|
|
|
"actor": {"email": user.email},
|
|
|
"slug": {"commit": ""},
|
|
|
"app": {"name": "example"},
|
|
|
+ "action": "update",
|
|
|
}
|
|
|
}
|
|
|
req.body = bytes(json.dumps(body), "utf-8")
|