Permalink
Browse files

[BUGFIX] Calls should be hung up when router executed controllers com…

…plete, not after everything executed by Call#execute_controller
  • Loading branch information...
1 parent ebe095e commit 1d4e302420df3013746ddeafd728a0838fdda642 @benlangfeld benlangfeld committed Mar 29, 2012
View
@@ -1,5 +1,6 @@
# [develop](https://github.com/adhearsion/adhearsion)
* Feature: `Call#execute_controller` now takes a post-execution callback (proc)
+ * Bugfix: Calls should be hung up when router executed controllers complete, not after everything executed by `Call#execute_controller`
* Bugfix: Deal with race conditions raising exceptions when hanging up calls after a controller executes
# [2.0.0.rc3](https://github.com/adhearsion/adhearsion/compare/v2.0.0.rc2...v2.0.0.rc3) - [2012-03-23](https://rubygems.org/gems/adhearsion/versions/2.0.0.rc3)
@@ -265,12 +265,8 @@ def execute_controller(controller, completion_callback = nil)
begin
CallController.exec controller
ensure
- begin
- call.hangup
- rescue Hangup
- end
+ completion_callback.call call if completion_callback
end
- completion_callback.call call if completion_callback
end
end.tap { |t| Adhearsion::Process.important_threads << t }
end
@@ -29,7 +29,12 @@ def dispatcher
target.new call
end
- call.execute_controller controller
+ call.execute_controller controller, lambda { |call|
+ begin
+ call.hangup
+ rescue Hangup
+ end
+ }
end
end
@@ -621,13 +621,6 @@ def expect_unjoin_with_options(options = {})
latch.wait(3).should be_true
end
- it "should hangup the call after all controllers have executed" do
- flexmock(CallController).should_receive(:exec).once.with mock_controller
- subject.should_receive(:hangup).once
- subject.execute_controller mock_controller, lambda { |call| latch.countdown! }
- latch.wait(3).should be_true
- end
-
it "should add the controller thread to the important threads" do
flexmock(CallController).should_receive(:exec)
controller_thread = subject.execute_controller mock_controller, lambda { |call| latch.countdown! }
@@ -107,7 +107,12 @@ def should_not_match_the_call
let(:route) { Route.new 'foobar', controller }
it "should instruct the call to use an instance of the controller" do
- flexmock(call).should_receive(:execute_controller).once.with controller
+ flexmock(call).should_receive(:execute_controller).once.with controller, Proc
+ route.dispatcher.call call
+ end
+
+ it "should hangup the call after all controllers have executed" do
+ flexmock(call).should_receive(:hangup).once
route.dispatcher.call call
end
end
@@ -120,7 +125,7 @@ def should_not_match_the_call
end
it "should instruct the call to use a CallController with the correct block" do
- flexmock(call).should_receive(:execute_controller).once.with(CallController).and_return do |controller|
+ flexmock(call).should_receive(:execute_controller).once.with(CallController, Proc).and_return do |controller|
controller.block.call.should be == :foobar
end
route.dispatcher.call call

0 comments on commit 1d4e302

Please sign in to comment.