public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fix FCGI dispatching tests

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
ffmike (author)
Sun Dec 28 18:31:33 -0800 2008
lifo (committer)
Mon Dec 29 11:58:10 -0800 2008
commit  36af857c435cbbdb43f5a7bed200ddaa5e10ef80
tree    2a4dbecaeba6ba983549096f3fcfd0cbf56a69f0
parent  c20c72e3d9321f8c00587aab479d962e80b02c35
...
1
2
3
 
4
5
6
7
8
9
10
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
 
 
147
148
149
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
...
217
218
219
220
 
221
222
223
...
238
239
240
241
 
242
243
244
...
254
255
256
257
 
258
259
260
...
284
285
286
287
 
288
289
290
...
1
2
3
4
5
6
 
 
7
8
9
...
130
131
132
 
 
 
 
 
 
 
 
 
 
133
134
135
136
137
138
139
140
...
150
151
152
 
 
 
 
 
 
 
 
 
 
 
 
 
153
154
155
...
164
165
166
 
 
 
 
 
 
 
 
 
 
 
 
 
167
168
169
...
182
183
184
 
185
186
187
188
...
203
204
205
 
206
207
208
209
...
219
220
221
 
222
223
224
225
...
249
250
251
 
252
253
254
255
0
@@ -1,10 +1,9 @@
0
 require 'abstract_unit'
0
 
0
 begin
0
+require 'action_controller'
0
 require 'fcgi_handler'
0
 
0
-module ActionController; module Routing; module Routes; end end end
0
-
0
 class RailsFCGIHandlerTest < Test::Unit::TestCase
0
   def setup
0
     @log = StringIO.new
0
@@ -131,19 +130,11 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
0
     end
0
   end
0
 
0
-  class ::Dispatcher
0
-    class << self
0
-      attr_accessor :signal
0
-      alias_method :old_dispatch, :dispatch
0
-      def dispatch(cgi)
0
-        signal ? Process.kill(signal, $$) : old_dispatch
0
-      end
0
-    end
0
-  end
0
-
0
   def setup
0
     @log = StringIO.new
0
     @handler = RailsFCGIHandler.new(@log)
0
+    @dispatcher = mock
0
+    Dispatcher.stubs(:new).returns(@dispatcher)
0
   end
0
 
0
   def test_interrupted_via_HUP_when_not_in_request
0
@@ -159,19 +150,6 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
0
     assert_equal :reload, @handler.when_ready
0
   end
0
 
0
-  def test_interrupted_via_HUP_when_in_request
0
-    cgi = mock
0
-    FCGI.expects(:each_cgi).once.yields(cgi)
0
-    Dispatcher.expects(:signal).times(2).returns('HUP')
0
-
0
-    @handler.expects(:reload!).once
0
-    @handler.expects(:close_connection).never
0
-    @handler.expects(:exit).never
0
-
0
-    @handler.process!
0
-    assert_equal :reload, @handler.when_ready
0
-  end
0
-
0
   def test_interrupted_via_USR1_when_not_in_request
0
     cgi = mock
0
     FCGI.expects(:each_cgi).once.yields(cgi)
0
@@ -186,19 +164,6 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
0
     assert_nil @handler.when_ready
0
   end
0
 
0
-  def test_interrupted_via_USR1_when_in_request
0
-    cgi = mock
0
-    FCGI.expects(:each_cgi).once.yields(cgi)
0
-    Dispatcher.expects(:signal).times(2).returns('USR1')
0
-
0
-    @handler.expects(:reload!).never
0
-    @handler.expects(:close_connection).with(cgi).once
0
-    @handler.expects(:exit).never
0
-
0
-    @handler.process!
0
-    assert_equal :exit, @handler.when_ready
0
-  end
0
-
0
   def test_restart_via_USR2_when_in_request
0
     cgi = mock
0
     FCGI.expects(:each_cgi).once.yields(cgi)
0
@@ -217,7 +182,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
0
   def test_interrupted_via_TERM
0
     cgi = mock
0
     FCGI.expects(:each_cgi).once.yields(cgi)
0
-    Dispatcher.expects(:signal).times(2).returns('TERM')
0
+    ::Rack::Handler::FastCGI.expects(:serve).once.returns('TERM')
0
 
0
     @handler.expects(:reload!).never
0
     @handler.expects(:close_connection).never
0
@@ -238,7 +203,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
0
     cgi = mock
0
     error = RuntimeError.new('foo')
0
     FCGI.expects(:each_cgi).once.yields(cgi)
0
-    Dispatcher.expects(:dispatch).once.with(cgi).raises(error)
0
+    ::Rack::Handler::FastCGI.expects(:serve).once.raises(error)
0
     @handler.expects(:dispatcher_error).with(error, regexp_matches(/^unhandled/))
0
     @handler.process!
0
   end
0
@@ -254,7 +219,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
0
     cgi = mock
0
     error = SignalException.new('USR2')
0
     FCGI.expects(:each_cgi).once.yields(cgi)
0
-    Dispatcher.expects(:dispatch).once.with(cgi).raises(error)
0
+    ::Rack::Handler::FastCGI.expects(:serve).once.raises(error)
0
     @handler.expects(:dispatcher_error).with(error, regexp_matches(/^stopping/))
0
     @handler.process!
0
   end
0
@@ -284,7 +249,7 @@ class RailsFCGIHandlerPeriodicGCTest < Test::Unit::TestCase
0
 
0
     cgi = mock
0
     FCGI.expects(:each_cgi).times(10).yields(cgi)
0
-    Dispatcher.expects(:dispatch).times(10).with(cgi)
0
+    Dispatcher.expects(:new).times(10)
0
 
0
     @handler.expects(:run_gc!).never
0
     9.times { @handler.process! }

Comments