aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/live.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-02-28 15:22:35 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-02-28 15:22:43 -0800
commit30d21dfcb7fafe49b3805b8249454485a90097b6 (patch)
treec63242b81200e976954bd0802ef3c9f4611b0971 /actionpack/lib/action_controller/metal/live.rb
parentbe6f51a487eb412ca29765aa7e84d2f13a688891 (diff)
downloadrails-30d21dfcb7fafe49b3805b8249454485a90097b6.tar.gz
rails-30d21dfcb7fafe49b3805b8249454485a90097b6.tar.bz2
rails-30d21dfcb7fafe49b3805b8249454485a90097b6.zip
live controllers should have live responses
detect the type of controller we're testing and return the right type of response based on that controller. This allows us to stop doing the weird sleep thing.
Diffstat (limited to 'actionpack/lib/action_controller/metal/live.rb')
-rw-r--r--actionpack/lib/action_controller/metal/live.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb
index 5ef4f6ccda..fba17746c0 100644
--- a/actionpack/lib/action_controller/metal/live.rb
+++ b/actionpack/lib/action_controller/metal/live.rb
@@ -107,8 +107,11 @@ module ActionController
end
class Buffer < ActionDispatch::Response::Buffer #:nodoc:
+ include MonitorMixin
+
def initialize(response)
@error_callback = lambda { true }
+ @cv = new_cond
super(response, SizedQueue.new(10))
end
@@ -128,8 +131,17 @@ module ActionController
end
def close
- super
- @buf.push nil
+ synchronize do
+ super
+ @buf.push nil
+ @cv.broadcast
+ end
+ end
+
+ def await_close
+ synchronize do
+ @cv.wait_until { @closed }
+ end
end
def on_error(&block)