Sha256: a4de4bd289aacbf362919ad2dd9453213946009c810b829f0d26bcd8b070bb82

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

# encoding: UTF-8

require "spec_helper"

describe Timber::Events::HTTPRequest, :rails_23 => true do
  describe ".initialize" do
    it "should coerce content_length into an integer" do
      event = described_class.new(:method => 'GET', :content_length => "123")
      expect(event.content_length).to eq(123)
    end

    context "with a header filters" do
      around(:each) do |example|
        old_http_header_filters = Timber::Config.instance.http_header_filters
        Timber::Config.instance.http_header_filters += ['api-key']
        example.run
        Timber::Config.instance.http_header_filters = old_http_header_filters
      end

      it "should sanitize headers when a config option is set" do
        event = described_class.new(:headers => {'Api-Key' => 'abcde'}, :host => 'my.host.com', :method => 'GET', :path => '/path', :scheme => 'https')
        expect(event.headers).to eq({'api-key' => '[sanitized]'})
      end
    end

    it "should handle header encoding" do
      referer = 'http://www.metrojobb.se/jobb/1013893-skadeadministratör'.force_encoding('ASCII-8BIT')
      event = described_class.new(:headers => {'Referer' => referer}, :host => 'my.host.com', :method => 'GET', :path => '/path', :scheme => 'https')
      expect(event.headers["referer"].encoding).to eq(::Encoding::UTF_8)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
timber-2.6.2 spec/timber/events/http_request_spec.rb
timber-2.6.1 spec/timber/events/http_request_spec.rb
timber-2.6.0 spec/timber/events/http_request_spec.rb
timber-2.6.0.pre.beta2 spec/timber/events/http_request_spec.rb
timber-2.6.0.pre.beta1 spec/timber/events/http_request_spec.rb