support stream parameter for jira to override default stream

(imported from commit b3be7b837f326968f9742c25ba04bdaaf6476b75)
This commit is contained in:
Steve Howell 2013-04-30 11:35:43 -04:00
parent e9ea54b9ec
commit 23f0d0bcb7
2 changed files with 20 additions and 1 deletions

View File

@ -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")

View File

@ -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()