Sha256: a92c8ca247d15a6ebdcd1aab32bd4854b6a9221b04a517beda7ce78c194a944b

Contents?: true

Size: 895 Bytes

Versions: 9

Compression:

Stored size: 895 Bytes

Contents

RSpec.describe Airbrake::Rack::SessionFilter do
  def env_for(url, opts = {})
    Rack::MockRequest.env_for(url, opts)
  end

  let(:notice) do
    Airbrake.build_notice('oops').tap do |notice|
      notice.stash[:rack_request] = Rack::Request.new(env_for(uri, opts))
    end
  end

  context "when rack session is nil" do
    let(:uri) { '/' }

    let(:opts) do
      { 'rack.session' => nil }
    end

    it "doesn't overwrite the session key with nil" do
      expect(notice[:session]).to eq({})

      subject.call(notice)

      expect(notice[:session]).to eq({})
    end
  end

  context "when session is present" do
    let(:session) do
      { a: 1, b: 2 }
    end

    let(:uri) { '/' }

    let(:opts) do
      { 'rack.session' => session }
    end

    it "sets session if it is present" do
      subject.call(notice)
      expect(notice[:session]).to eq(session)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
airbrake-9.2.1 spec/unit/rack/session_filter_spec.rb
airbrake-9.2.0 spec/unit/rack/session_filter_spec.rb
airbrake-9.1.0 spec/unit/rack/session_filter_spec.rb
airbrake-9.0.2 spec/unit/rack/session_filter_spec.rb
airbrake-9.0.1 spec/unit/rack/session_filter_spec.rb
airbrake-9.0.0 spec/unit/rack/session_filter_spec.rb
airbrake-8.3.2 spec/unit/rack/session_filter_spec.rb
airbrake-8.3.1 spec/unit/rack/session_filter_spec.rb
airbrake-8.3.0 spec/unit/rack/session_filter_spec.rb