-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
There are some straggler rails version-specific tests/code that are not currently running. Some may have been accidentally omitted from running on newer rails versions; others may have been logic specific to those rails versions that were not actually needed/wanted on newer versions.
- Dead code? (folder doesn't exist I think, but test is passing anyway with and without rails)
when '/WEB-INF' then File.expand_path('rails30/WEB-INF', STUB_DIR) - Body closing
jruby-rack/src/spec/ruby/jruby/rack/response_spec.rb
Lines 389 to 396 in 6f88954
it "closes original body during write_body", :lib => [:rails30, :rails31, :rails32] do body = wrap_file_body File.expand_path('../../files/image.jpg', File.dirname(__FILE__)) response = JRuby::Rack::Response.new [200, body.headers, body] expect(body).to receive(:close) response.write_body(response_environment) end - Dechunking?
- may or may not be used/needed now (need to investigate whether
JRuby::Rack::Response.dechunk = falseis used/needed still).
jruby-rack/src/spec/ruby/jruby/rack/response_spec.rb
Lines 156 to 239 in 6f88954
it "dechunks the body when a chunked response is detected", :lib => [:rails23, :rails31, :rails32, :rails40] do require 'rack/chunked' headers = { "Cache-Control" => 'no-cache', "Transfer-Encoding" => 'chunked' } body = [ "1".freeze, "\nsecond chunk", "a multi\nline chunk \n42", "utf-8 chunk 'ty píčo'!\n", "terminated chunk\r\n", "", # should be skipped "\r\nthe very\r\n last\r\n\r\n chunk" ] with_dechunk do body = Rack::Chunked::Body.new body response = JRuby::Rack::Response.new([200, headers, body]) response.write_headers(response_environment) times = 0 expect(stream).to receive(:write).exactly(6).times do |bytes| str = String.from_java_bytes(bytes) str = str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) case times += 1 when 1 then expect(str).to eq "1" when 2 then expect(str).to eq "\nsecond chunk" when 3 then expect(str).to eq "a multi\nline chunk \n42" when 4 then expect(str).to eq "utf-8 chunk 'ty píčo'!\n" when 5 then expect(str).to eq "terminated chunk\r\n" when 6 then expect(str).to eq "\r\nthe very\r\n last\r\n\r\n chunk" else fail("unexpected :write received with #{str.inspect}") end end expect(stream).to receive(:flush).exactly(6 + 1).times # +1 for tail chunk response.write_body(response_environment) end end it "does not dechunk body when dechunkins is turned off", :lib => [:rails31, :rails32, :rails40] do dechunk = JRuby::Rack::Response.dechunk? begin JRuby::Rack::Response.dechunk = false require 'rack/chunked' headers = { "Cache-Control" => 'no-cache', "Transfer-Encoding" => 'chunked' } body = [ "1".freeze, "\nsecond chunk", "" ] body = Rack::Chunked::Body.new body response = JRuby::Rack::Response.new([200, headers, body]) response.write_headers(response_environment) times = 0 expect(stream).to receive(:write).exactly(3).times do |bytes| str = String.from_java_bytes(bytes) case times += 1 when 1 then expect(str).to eq "1\r\n1\r\n" when 2 then expect(str).to eq "d\r\n\nsecond chunk\r\n" when 3 then expect(str).to eq "0\r\n\r\n" else fail("unexpected :write received with #{str.inspect}") end end expect(stream).to receive(:flush).exactly(3).times response.write_body(response_environment) ensure JRuby::Rack::Response.dechunk = dechunk end end
- may or may not be used/needed now (need to investigate whether
- Streaming files
jruby-rack/src/spec/ruby/jruby/rack/response_spec.rb
Lines 377 to 387 in 6f88954
it "streams a file using a channel if wrapped in body_parts", :lib => [:rails30, :rails31, :rails32] do body = wrap_file_body path = File.expand_path('../../files/image.jpg', File.dirname(__FILE__)) stream = self.stream response = JRuby::Rack::Response.new [200, body.headers, body] response.write_body(response_environment) expect_eql_java_bytes stream.to_java_bytes, File.read(path).to_java_bytes end
Would also be good to review and remove the associated code if they were specific to ancient rails versions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels