diff --git a/zephyr/tests.py b/zephyr/tests.py index e80910d974..b115b36cf2 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -2534,6 +2534,20 @@ class JiraHookTests(AuthedTestCase): stream_name="jira", content_type="application/json") + def test_custom_stream(self): + email = "hamlet@humbughq.com" + api_key = self.get_api_key(email) + action = 'created' + url = "/api/v1/external/jira/%s/?stream=jira_custom" % api_key + msg = self.send_json_payload(email, url, + self.fixture_data('jira', action), + stream_name="jira_custom", + content_type="application/json") + self.assertEqual(msg.subject, "BUG-15: New bug with hook") + self.assertEqual(msg.content, """Leo Franchi **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**: + +> New bug with hook""") + def test_created(self): msg = self.send_jira_message('created') self.assertEqual(msg.subject, "BUG-15: New bug with hook") diff --git a/zephyr/views.py b/zephyr/views.py index 7716536100..509480101b 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -1511,6 +1511,11 @@ def elide_subject(subject): def api_jira_webhook(request, api_key): payload = simplejson.loads(request.body) + try: + stream = request.GET['stream'] + except (AttributeError, KeyError): + stream = 'jira' + try: user_profile = UserProfile.objects.get(api_key=api_key) except UserProfile.DoesNotExist: @@ -1568,7 +1573,7 @@ def api_jira_webhook(request, api_key): subject = elide_subject(subject) - ret = check_send_message(user_profile, get_client("API"), "stream", ["jira"], subject, content) + ret = check_send_message(user_profile, get_client("API"), "stream", [stream], subject, content) if ret is not None: return json_error(ret) return json_success()