Skip to content

Commit

Permalink
Merge pull request #871 from Galathius/fix-rack-response-initialize
Browse files Browse the repository at this point in the history
Fix Grape::Middleware::Base#response
  • Loading branch information
dblock committed Dec 30, 2014
2 parents c1a5c7f + 05cfc5e commit fc5763d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/middleware/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions spec/grape/middleware/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc5763d

Please sign in to comment.