Skip to content

Commit

Permalink
Fix Rack::Response initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
Galathius committed Dec 29, 2014
1 parent c1a5c7f commit 31385a3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Next Release
============

* Your contribution here.
* [#868](https://github.com/intridea/grape/pull/871): Fixed Rack::Response initialize - [@galathius](https://github.com/galathius)

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
21 changes: 21 additions & 0 deletions spec/grape/middleware/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@
expect(subject.response).to be_kind_of(Rack::Response)
end

describe 'is created valid the 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({})
puts subject.response.header
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 31385a3

Please sign in to comment.