mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
Use stream from github webhook call (if supplied).
(imported from commit 4f57c4dec8ab5e833583a2b5912a92e8a2bd34c0)
This commit is contained in:
@@ -2651,20 +2651,7 @@ class BeanstalkHookTests(AuthedTestCase):
|
|||||||
class GithubHookTests(AuthedTestCase):
|
class GithubHookTests(AuthedTestCase):
|
||||||
fixtures = ['messages.json']
|
fixtures = ['messages.json']
|
||||||
|
|
||||||
def send_github_message(self, action):
|
def assert_content(self, msg):
|
||||||
email = "hamlet@humbughq.com"
|
|
||||||
api_key = self.get_api_key(email)
|
|
||||||
data = {'email': email,
|
|
||||||
'api-key': api_key,
|
|
||||||
'event': 'push',
|
|
||||||
'payload': self.fixture_data('github', action)}
|
|
||||||
return self.send_json_payload(email, "/api/v1/external/github",
|
|
||||||
data,
|
|
||||||
stream_name="commits")
|
|
||||||
|
|
||||||
def test_sample_hook(self):
|
|
||||||
msg = self.send_github_message('sample')
|
|
||||||
self.assertEqual(msg.subject, "grit")
|
|
||||||
self.assertEqual(msg.content, """rtomayko [pushed](http://github.com/mojombo/grit/compare/4c8124f...a47fd41) to branch master
|
self.assertEqual(msg.content, """rtomayko [pushed](http://github.com/mojombo/grit/compare/4c8124f...a47fd41) to branch master
|
||||||
|
|
||||||
* [06f63b4](http://github.com/mojombo/grit/commit/06f63b43050935962f84fe54473a7c5de7977325): stub git call for Grit#heads test f:15 Case#1
|
* [06f63b4](http://github.com/mojombo/grit/commit/06f63b43050935962f84fe54473a7c5de7977325): stub git call for Grit#heads test f:15 Case#1
|
||||||
@@ -2672,6 +2659,36 @@ class GithubHookTests(AuthedTestCase):
|
|||||||
* [a47fd41](http://github.com/mojombo/grit/commit/a47fd41f3aa4610ea527dcc1669dfdb9c15c5425): add more comments throughout
|
* [a47fd41](http://github.com/mojombo/grit/commit/a47fd41f3aa4610ea527dcc1669dfdb9c15c5425): add more comments throughout
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def test_user_specified_stream(self):
|
||||||
|
# Around May 2013 the github webhook started to specify the stream.
|
||||||
|
# Before then, the stream was hard coded to "commits".
|
||||||
|
email = "hamlet@humbughq.com"
|
||||||
|
api_key = self.get_api_key(email)
|
||||||
|
stream = 'my_commits'
|
||||||
|
data = {'email': email,
|
||||||
|
'api-key': api_key,
|
||||||
|
'stream': stream,
|
||||||
|
'event': 'push',
|
||||||
|
'payload': self.fixture_data('github', 'sample')}
|
||||||
|
msg = self.send_json_payload(email, "/api/v1/external/github",
|
||||||
|
data,
|
||||||
|
stream_name=stream)
|
||||||
|
self.assertEqual(msg.subject, "grit")
|
||||||
|
self.assert_content(msg)
|
||||||
|
|
||||||
|
def test_legacy_hook(self):
|
||||||
|
email = "hamlet@humbughq.com"
|
||||||
|
api_key = self.get_api_key(email)
|
||||||
|
data = {'email': email,
|
||||||
|
'api-key': api_key,
|
||||||
|
'event': 'push',
|
||||||
|
'payload': self.fixture_data('github', 'sample')}
|
||||||
|
msg = self.send_json_payload(email, "/api/v1/external/github",
|
||||||
|
data,
|
||||||
|
stream_name="commits")
|
||||||
|
self.assertEqual(msg.subject, "grit")
|
||||||
|
self.assert_content(msg)
|
||||||
|
|
||||||
class PivotalHookTests(AuthedTestCase):
|
class PivotalHookTests(AuthedTestCase):
|
||||||
fixtures = ['messages.json']
|
fixtures = ['messages.json']
|
||||||
|
|
||||||
|
|||||||
@@ -1459,7 +1459,8 @@ def build_message_from_gitlog(user_profile, name, ref, commits, before, after, u
|
|||||||
@authenticated_api_view
|
@authenticated_api_view
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def api_github_landing(request, user_profile, event=POST,
|
def api_github_landing(request, user_profile, event=POST,
|
||||||
payload=POST(converter=json_to_dict)):
|
payload=POST(converter=json_to_dict),
|
||||||
|
stream=POST(default='commits')):
|
||||||
# TODO: this should all be moved to an external bot
|
# TODO: this should all be moved to an external bot
|
||||||
repository = payload['repository']
|
repository = payload['repository']
|
||||||
|
|
||||||
@@ -1499,7 +1500,7 @@ def api_github_landing(request, user_profile, event=POST,
|
|||||||
request.client = get_client("github_bot")
|
request.client = get_client("github_bot")
|
||||||
return send_message_backend(request, user_profile,
|
return send_message_backend(request, user_profile,
|
||||||
message_type_name="stream",
|
message_type_name="stream",
|
||||||
message_to=["commits"],
|
message_to=[stream],
|
||||||
forged=False, subject_name=subject,
|
forged=False, subject_name=subject,
|
||||||
message_content=content)
|
message_content=content)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user