Permalink
Browse files

Add flag for only announcing commits to master.

  • Loading branch information...
1 parent 7f132d5 commit 8bc16db79f986106151939af22d4a602b5f6dd4c @bgreenlee bgreenlee committed Sep 7, 2011
Showing with 21 additions and 1 deletion.
  1. +3 −1 services/campfire.rb
  2. +18 −0 test/campfire_test.rb
View
@@ -1,10 +1,12 @@
class Service::Campfire < Service
string :subdomain, :room, :token
- boolean :play_sound
+ boolean :master_only, :play_sound
def receive_push
raise_config_error 'Missing campfire token' if data['token'].to_s.empty?
+ return if data['master_only'].to_i == 1 and branch_name != 'master'
+
messages = []
messages << "#{summary_message}: #{summary_url}"
messages += commit_messages.first(8)
View
@@ -48,6 +48,24 @@ def test_push
assert_equal 4, svc.campfire.rooms.first.lines.size # 3 + summary
end
+ def test_push_non_master_with_master_only
+ non_master_payload = payload
+ non_master_payload["ref"] = "refs/heads/non-master"
+ svc = service({"token" => "t", "subdomain" => "s", "room" => "r", "master_only" => 1}, non_master_payload)
+ svc.campfire = MockCampfire.new
+ svc.receive_push
+ assert_equal 0, svc.campfire.rooms.size
+ end
+
+ def test_push_non_master_without_master_only
+ non_master_payload = payload
+ non_master_payload["ref"] = "refs/heads/non-master"
+ svc = service({"token" => "t", "subdomain" => "s", "room" => "r", "master_only" => 0}, non_master_payload)
+ svc.campfire = MockCampfire.new
+ svc.receive_push
+ assert_equal 4, svc.campfire.rooms.first.lines.size # 3 + summary
+ end
+
def service(*args)
super Service::Campfire, *args
end

1 comment on commit 8bc16db

That's interesting. But it's be cool if it could guess the repository's default branch and use it instead of hardcoding it to master.

Please sign in to comment.