Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add stream/branches fields for HumBug

  • Loading branch information...
commit fb0633f642edcac258e9ef32a2e24867b23113c0 1 parent 5164d24
Steve Howell authored
Showing with 18 additions and 3 deletions.
  1. +2 −0  docs/humbug
  2. +8 −1 lib/services/humbug.rb
  3. +8 −2 test/humbug_test.rb
View
2  docs/humbug
@@ -3,3 +3,5 @@ Install Notes
1. **Email** - The user to authenticate as.
2. **Api Key** - The API key associated with the provided user. See: https://humbughq.com/#settings
+3. **Stream** - The Humbug stream where you want messages to be sent. (If you leave this blank, it defaults to the "commits" stream in Humbug.) Whether you use the default stream or specify it explicitly, you need to set up the stream on the Humbug side.
+4. **Branches** - If you want to restrict Humbug notifications to certain GitHub branches, then provide a comma delimited list of git branches here (e.g. master,staging,prod). Otherwise, leave it empty.
View
9 lib/services/humbug.rb
@@ -1,8 +1,11 @@
class Service::Humbug < Service
string :email
string :api_key
+ string :stream
+ string :branches
white_list :email
+ white_list :branches
default_events :commit_comment, :create, :delete, :download, :follow, :fork,
:fork_apply, :gist, :gollum, :issue_comment, :issues, :member, :public,
@@ -13,9 +16,13 @@ def receive_event
raise_config_error "Missing 'email'" if data['email'].to_s == ''
raise_config_error "Missing 'api_key'" if data['api_key'].to_s == ''
- res = http_post "https://humbughq.com/api/v1/external/github",
+ # url = 'http://localhost:9991/api/v1/external/github'
+ url = 'https://humbughq.com/api/v1/external/github'
+ res = http_post url,
:email => data['email'],
'api-key' => data['api_key'],
+ 'stream' => data['stream'],
+ 'branches' => data['branches'],
:event => event,
:payload => generate_json(payload)
if not res.success?
View
10 test/humbug_test.rb
@@ -13,6 +13,8 @@ def post_checker(event)
assert_match "email=e", env[:body]
assert_match "api-key=a", env[:body]
assert_match "event=" + event, env[:body]
+ assert_match "stream=commits", env[:body]
+ assert_match "branches=b1%2Cb2", env[:body]
return [200, {}, ''] }
end
@@ -20,7 +22,9 @@ def test_push
checker = post_checker "push"
@stubs.post "/api/v1/external/github", &checker
- svc = service(:push, {'email' => 'e', 'api_key' => 'a'}, {'test' => 'payload'})
+ svc = service(:push,
+ {'email' => 'e', 'api_key' => 'a', 'stream' => 'commits', 'branches' => 'b1,b2'},
+ {'test' => 'payload'})
svc.receive_event
end
@@ -28,7 +32,9 @@ def test_pull_request
checker = post_checker "pull_request"
@stubs.post "/api/v1/external/github", &checker
- svc = service(:pull_request, {'email' => 'e', 'api_key' => 'a'}, {'test' => 'payload'})
+ svc = service(:pull_request,
+ {'email' => 'e', 'api_key' => 'a', 'stream' => 'commits', 'branches' => 'b1,b2'},
+ {'test' => 'payload'})
svc.receive_event
end
Please sign in to comment.
Something went wrong with that request. Please try again.