Sha256: 4a3cc9afca8af43e595b03af11484729d631c213ade4eecec55d2f85b324c7bf

Contents?: true

Size: 915 Bytes

Versions: 4

Compression:

Stored size: 915 Bytes

Contents

# encoding: utf-8
require 'test_helper'

class RequestTest < Test::Unit::TestCase
  class MockRequest
    include Geocoder::Request
    attr_accessor :env, :ip
    def initialize(env={}, ip="")
      @env = env
      @ip  = ip
    end
  end
  def test_http_x_real_ip
    req = MockRequest.new({"HTTP_X_REAL_IP" => "74.200.247.59"})
    assert req.location.is_a?(Geocoder::Result::Freegeoip)
  end
  def test_http_x_forwarded_for_without_proxy
    req = MockRequest.new({"HTTP_X_FORWARDED_FOR" => "74.200.247.59"})
    assert req.location.is_a?(Geocoder::Result::Freegeoip)
  end
  def test_http_x_forwarded_for_with_proxy
    req = MockRequest.new({"HTTP_X_FORWARDED_FOR" => "74.200.247.59, 74.200.247.59"})
    assert req.location.is_a?(Geocoder::Result::Freegeoip)
  end
  def test_with_request_ip
    req = MockRequest.new({}, "74.200.247.59")
    assert req.location.is_a?(Geocoder::Result::Freegeoip)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
geocoder-1.1.9 test/request_test.rb
geocoder-1.1.8 test/request_test.rb
geocoder-1.1.7 test/request_test.rb
geocoder-sgonyea-1.1.6.1 test/request_test.rb