Sha256: e8505d4d45265b47c7f3496b0719bc86dff1ae086a2d95dfa5de9964db3716dc
Contents?: true
Size: 936 Bytes
Versions: 14
Compression:
Stored size: 936 Bytes
Contents
require 'sitehub/middleware/transaction_id' class SiteHub module Middleware describe TransactionId do let(:transaction_id) { Constants::HttpHeaderKeys::TRANSACTION_ID } subject do described_class.new(proc {}) end let(:request) { Request.new(env: {}) } let(:env) { { REQUEST => request } } it 'adds a unique identifier to the request' do uuid = UUID.generate(:compact) expect(UUID).to receive(:generate).with(:compact).and_return(uuid) subject.call(env) expect(request.headers[transaction_id]).to eq(uuid) end context 'transaction id header already exists' do it 'leaves it intact' do expect(UUID).to_not receive(:generate) request.headers[transaction_id] = :existing_id subject.call(env) expect(request.headers[transaction_id]).to eq(:existing_id) end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems