Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Rack::Files::Iterator responses #576

Merged
merged 1 commit into from Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bullet/rack.rb
Expand Up @@ -84,7 +84,7 @@ def html_request?(headers, response)
def response_body(response)
if response.respond_to?(:body)
Array === response.body ? response.body.first : response.body
else
elsif response.respond_to?(:first)
response.first
end
end
Expand Down
11 changes: 11 additions & 0 deletions spec/bullet/rack_spec.rb
Expand Up @@ -2,6 +2,8 @@

require 'spec_helper'

require 'rack/files'

module Bullet
describe Rack do
let(:middleware) { Bullet::Rack.new app }
Expand Down Expand Up @@ -261,6 +263,15 @@ module Bullet
expect(middleware.response_body(response)).to eq body_string
end
end

context 'when `response` is a Rack::Files::Iterator' do
let(:response) { instance_double(::Rack::Files::Iterator) }
before { allow(response).to receive(:is_a?).with(::Rack::Files::Iterator) { true } }

it 'should return nil' do
expect(middleware.response_body(response)).to be_nil
end
end
end
end
end