diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e784bb27..963d43eeb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Next Release ============ +* [#871](https://github.com/intridea/grape/pull/871): Fixed Grape::Middleware::Base#response - [@galathius](https://github.com/galathius). * Your contribution here. 0.10.1 (12/28/2014) diff --git a/lib/grape/middleware/base.rb b/lib/grape/middleware/base.rb index ba400a14d6..3bbaf6bd7c 100644 --- a/lib/grape/middleware/base.rb +++ b/lib/grape/middleware/base.rb @@ -37,7 +37,7 @@ def after end def response - Rack::Response.new(@app_response) + Rack::Response.new(@app_response[2], @app_response[0], @app_response[1]) end def content_type_for(format) diff --git a/spec/grape/middleware/base_spec.rb b/spec/grape/middleware/base_spec.rb index 8df558f030..7ee6e05afe 100644 --- a/spec/grape/middleware/base_spec.rb +++ b/spec/grape/middleware/base_spec.rb @@ -34,6 +34,26 @@ expect(subject.response).to be_kind_of(Rack::Response) end + describe '#response' do + subject { Grape::Middleware::Base.new(response) } + let(:response) { lambda { |_| [204, { abc: 1 }, 'test'] } } + + it 'status' do + subject.call({}) + expect(subject.response.status).to eq(204) + end + + it 'body' do + subject.call({}) + expect(subject.response.body).to eq(['test']) + end + + it 'header' do + subject.call({}) + expect(subject.response.header).to have_key(:abc) + end + end + context 'options' do it 'persists options passed at initialization' do expect(Grape::Middleware::Base.new(blank_app, abc: true).options[:abc]).to be true