Fully quote payload body contents in integrations

(imported from commit 3cb03eabbd917f878b37aa226eb3f3ecda63d5e7)
This commit is contained in:
Zev Benjamin
2013-09-16 12:44:50 -04:00
parent b8e68a5a17
commit e5cf24b2fd
2 changed files with 15 additions and 9 deletions

View File

@@ -3111,7 +3111,9 @@ class JiraHookTests(AuthedTestCase):
self.assertEqual(msg.content, """Leo Franchi **updated** [BUG-15](http://lfranchi.com:8080/browse/BUG-15): self.assertEqual(msg.content, """Leo Franchi **updated** [BUG-15](http://lfranchi.com:8080/browse/BUG-15):
> Adding a comment. Oh, what a comment it is!""") ~~~ quote
Adding a comment. Oh, what a comment it is!
~~~""")
def test_deleted(self): def test_deleted(self):
msg = self.send_jira_message('deleted') msg = self.send_jira_message('deleted')
@@ -3133,7 +3135,9 @@ class JiraHookTests(AuthedTestCase):
* Changed status from **Resolved** to **Reopened** * Changed status from **Resolved** to **Reopened**
> Re-opened yeah!""") ~~~ quote
Re-opened yeah!
~~~""")
def test_resolved(self): def test_resolved(self):
msg = self.send_jira_message('resolved') msg = self.send_jira_message('resolved')
@@ -3144,7 +3148,9 @@ class JiraHookTests(AuthedTestCase):
* Changed status from **Open** to **Resolved** * Changed status from **Open** to **Resolved**
* Changed assignee from **None** to **Leo Franchi** * Changed assignee from **None** to **Leo Franchi**
> Fixed it, finally!""") ~~~ quote
Fixed it, finally!
~~~""")
def test_workflow_postfuncion(self): def test_workflow_postfuncion(self):
msg = self.send_jira_message('postfunction_hook') msg = self.send_jira_message('postfunction_hook')
@@ -3328,7 +3334,7 @@ class PivotalHookTests(AuthedTestCase):
msg = self.send_pivotal_message('created') msg = self.send_pivotal_message('created')
self.assertEqual(msg.subject, 'My new Feature story') self.assertEqual(msg.subject, 'My new Feature story')
self.assertEqual(msg.content, 'Leo Franchi added "My new Feature story" \ self.assertEqual(msg.content, 'Leo Franchi added "My new Feature story" \
(unscheduled feature):\n\n> This is my long description\n\n \ (unscheduled feature):\n\n~~~ quote\nThis is my long description\n~~~\n\n \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)') [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)')
def test_delivered(self): def test_delivered(self):
@@ -3365,7 +3371,7 @@ class PivotalHookTests(AuthedTestCase):
msg = self.send_pivotal_message('created_estimate') msg = self.send_pivotal_message('created_estimate')
self.assertEqual(msg.subject, 'Another new story') self.assertEqual(msg.subject, 'Another new story')
self.assertEqual(msg.content, 'Leo Franchi added "Another new story" \ self.assertEqual(msg.content, 'Leo Franchi added "Another new story" \
(unscheduled feature worth 2 story points):\n\n> Some loong description\n\n \ (unscheduled feature worth 2 story points):\n\n~~~ quote\nSome loong description\n~~~\n\n \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)') [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)')
def test_type_changed(self): def test_type_changed(self):

View File

@@ -46,7 +46,7 @@ def api_github_landing(request, user_profile, event=REQ,
subject = "%s: pull request %d" % (repository['name'], subject = "%s: pull request %d" % (repository['name'],
pull_req['number']) pull_req['number'])
content = ("Pull request from %s [%s](%s):\n\n %s\n\n> %s" content = ("Pull request from %s [%s](%s):\n\n %s\n\n~~~ quote\n%s\n~~~"
% (pull_req['user']['login'], % (pull_req['user']['login'],
payload['action'], payload['action'],
pull_req['html_url'], pull_req['html_url'],
@@ -79,7 +79,7 @@ def api_github_landing(request, user_profile, event=REQ,
issue = payload['issue'] issue = payload['issue']
subject = "%s: issue %d %s" % (repository['name'], issue['number'], payload['action']) subject = "%s: issue %d %s" % (repository['name'], issue['number'], payload['action'])
content = ("%s %s [issue %d](%s): %s\n\n> %s" content = ("%s %s [issue %d](%s): %s\n\n~~~ quote\n%s\n~~~"
% (payload['sender']['login'], % (payload['sender']['login'],
payload['action'], payload['action'],
issue['number'], issue['number'],
@@ -219,7 +219,7 @@ def api_jira_webhook(request):
content += "* Changed %s from **%s** to **%s**\n" % (field, item.get('fromString'), item.get('toString')) content += "* Changed %s from **%s** to **%s**\n" % (field, item.get('fromString'), item.get('toString'))
if comment != '': if comment != '':
content += "\n> %s" % (comment,) content += "\n~~~ quote\n%s\n~~~" % (comment,)
elif 'transition' in payload: elif 'transition' in payload:
from_status = get_in(payload, ['transition', 'from_status']) from_status = get_in(payload, ['transition', 'from_status'])
to_status = get_in(payload, ['transition', 'to_status']) to_status = get_in(payload, ['transition', 'to_status'])
@@ -295,7 +295,7 @@ def api_pivotal_webhook(request):
if estimate != '': if estimate != '':
estimate = " worth %s story points" % (estimate,) estimate = " worth %s story points" % (estimate,)
subject = name subject = name
content = "%s (%s %s%s):\n\n> %s\n\n%s" % (description, content = "%s (%s %s%s):\n\n~~~ quote\n%s\n~~~\n\n%s" % (description,
issue_status, issue_status,
issue_type, issue_type,
estimate, estimate,