Sha256: 7ab69c39ac685df86a3b12801f4af6952830e8a9441d174438a8ecfd41187c84

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

require File.dirname(__FILE__) + '/helper'

class RequestTest < Test::Unit::TestCase
  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

  it 'is secure when the url scheme is https' do
    request = Sinatra::Request.new('rack.url_scheme' => 'https')
    assert request.secure?
  end

  it 'is not secure when the url scheme is http' do
    request = Sinatra::Request.new('rack.url_scheme' => 'http')
    assert !request.secure?
  end

  it 'respects X-Forwarded-Proto header for proxied SSL' do
    request = Sinatra::Request.new('HTTP_X_FORWARDED_PROTO' => 'https')
    assert request.secure?
  end
end

Version data entries

12 entries across 12 versions & 7 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/sinatra-1.0/test/request_test.rb
adamwiggins-sinatra-0.10.1 test/request_test.rb
sinatra-base-1.0 test/request_test.rb
sinatra-1.0 test/request_test.rb
sinatra-1.0.b test/request_test.rb
sinatra-bundles-0.1.2 vendor/gems/sinatra-0.10.1/test/request_test.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/sinatra-1.0.a/test/request_test.rb
sinatra-1.0.a test/request_test.rb
sinatra-bundles-0.1.1 vendor/gems/sinatra-0.10.1/test/request_test.rb
sinatra-bundles-0.1.0 vendor/gems/sinatra-0.10.1/test/request_test.rb
sinatra-bundles-0.0.2 vendor/gems/sinatra-0.10.1/test/request_test.rb
darkhelmet-sinatra-0.10.1 test/request_test.rb