1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/test/request_test.rb
Ryan Tomayko 4a75d9edfb Fix Request#params on PUT requests [#72]
Works around an issue introduced in Rack 0.9.0 with
request body params not being parsed when the request method
is PUT. This should be reverted once a fix lands in Rack.

Ticket for Rack fix:
http://rack.lighthouseapp.com/projects/22435-rack/tickets/20

More:
http://sinatra.lighthouseapp.com/projects/9779/tickets/72
2009-01-15 06:45:42 -08:00

18 lines
571 B
Ruby

require File.dirname(__FILE__) + '/helper'
describe 'Sinatra::Request' do
it 'responds to #user_agent' do
request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
assert request.respond_to?(:user_agent)
assert_equal 'Test', request.user_agent
end
it 'parses POST params when Content-Type is form-dataish' do
request = Sinatra::Request.new(
'REQUEST_METHOD' => 'PUT',
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
'rack.input' => StringIO.new('foo=bar')
)
assert_equal 'bar', request.params['foo']
end
end