Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Pull Request notifications to Talker

  • Loading branch information...
commit df6750e304a0aaba61363afc0f5f36f1ef794d9a 1 parent 45dd9f2
@Mange Mange authored
Showing with 25 additions and 9 deletions.
  1. +14 −4 services/talker.rb
  2. +11 −5 test/talker_test.rb
View
18 services/talker.rb
@@ -6,11 +6,8 @@ def receive_push
repository = payload['repository']['name']
branch = branch_name
commits = payload['commits']
- token = data['token']
- http.ssl[:verify] = false
- http.headers["X-Talker-Token"] = token
- http.url_prefix = data['url']
+ prepare_http
say "#{summary_message}#{summary_url}"
if data['digest'].to_i == 0
@@ -25,7 +22,20 @@ def receive_push
end
end
+ def receive_pull_request
+ return unless opened?
+
+ prepare_http
+ say summary_message
+ end
+
private
+ def prepare_http
+ http.ssl[:verify] = false
+ http.headers["X-Talker-Token"] = data['token']
+ http.url_prefix = data['url']
+ end
+
def say(message)
http_post 'messages.json', :message => message
end
View
16 test/talker_test.rb
@@ -8,7 +8,7 @@ def setup
def test_push_with_digest_on
expect_message_posting
- svc = service({'digest' => '1'}, push_payload)
+ svc = service(:push, {'digest' => '1'}, push_payload)
svc.receive_push
end
@@ -18,7 +18,7 @@ def test_push_with_digest_off_and_several_distinct_commits
payload = push_payload
assert payload['commits'].size > 1
- svc = service({'digest' => '0'}, payload)
+ svc = service(:push, {'digest' => '0'}, payload)
svc.receive_push
end
@@ -28,13 +28,19 @@ def test_push_with_digest_off_and_a_single_distinct_commit
payload = push_payload
payload['commits'] = [payload['commits'].first]
- svc = service({'digest' => '0'}, payload)
+ svc = service(:push, {'digest' => '0'}, payload)
svc.receive_push
end
- def service(options, *args)
+ def test_pull_request
+ expect_message_posting
+ svc = service(:pull_request, {}, pull_payload)
+ svc.receive_pull_request
+ end
+
+ def service(event, options = {}, *args)
default_options = {'url' => 'https://s.talkerapp.com/room/1', 'token' => 't'}
- super Service::Talker, default_options.merge(options), *args
+ super Service::Talker, event, default_options.merge(options), *args
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.