Skip to content

Commit

Permalink
protection against eventual notifiers timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Nov 20, 2008
1 parent a10e36a commit c969e8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/integrity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require 'yaml'
require 'logger'
require 'digest/sha1'
require 'timeout'

require "core_ext/object"
require "core_ext/string"
Expand Down
4 changes: 3 additions & 1 deletion lib/integrity/notifier/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module Integrity
class Notifier
class Base
def self.notify_of_build(build, config)
new(build, config).deliver!
Timeout.timeout(6) do
new(build, config).deliver!
end
end

def self.to_haml
Expand Down
6 changes: 6 additions & 0 deletions spec/notifier/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def klass
notifier.should_receive(:deliver!)
klass.notify_of_build(mock_build, notifier_config)
end

it "should protect itself from timeout" do
lambda do
notifier.stub!(:deliver!).and_raise(Timeout::Error)
end.should_not raise_error
end
end

describe "generating the config form" do
Expand Down

0 comments on commit c969e8c

Please sign in to comment.