|
104 | 104 | let(:route_set) { double('ActionDispatch::Routing::RouteSet', router: router) } |
105 | 105 | let(:request) { double('Rack::Request', env: {}, script_name: '', path: '/users/1') } |
106 | 106 |
|
107 | | - it { expect(described_class.route_pattern(request)).to eq('/users/1') } |
| 107 | + it { expect(described_class.route_pattern(request)).to eq('/users/{param:int}') } |
| 108 | + |
| 109 | + it 'persists inferred route in the request env' do |
| 110 | + expect { described_class.route_pattern(request) } |
| 111 | + .to change { request.env[Datadog::Tracing::Contrib::Rack::Ext::DATADOG_INFERRED_ROUTE] } |
| 112 | + .from(nil).to('/users/{param:int}') |
| 113 | + end |
108 | 114 | end |
109 | 115 |
|
110 | 116 | context 'when route_uri_pattern is not set and request path_parameters is present' do |
|
130 | 136 | let(:action_dispatch_request) { double('ActionDispatch::Request', env: {}, script_name: '', path: '/users/1') } |
131 | 137 |
|
132 | 138 | it 'uses action dispatch request for route recognition' do |
133 | | - expect(router).to receive(:recognize).with(action_dispatch_request).and_return('/users/1') |
134 | | - expect(described_class.route_pattern(request)).to eq('/users/1') |
| 139 | + expect(router).to receive(:recognize).with(action_dispatch_request).and_return('/users/:id(.:format)') |
| 140 | + expect(described_class.route_pattern(request)).to eq('/users/:id') |
135 | 141 | end |
136 | 142 | end |
137 | 143 |
|
|
143 | 149 | let(:request) { double('Rack::Request', env: {}, script_name: '', path: '/users/1', head?: false) } |
144 | 150 |
|
145 | 151 | it 'uses action dispatch request for route recognition' do |
146 | | - expect(router).to receive(:recognize).with(request).and_return('/users/1') |
147 | | - expect(described_class.route_pattern(request)).to eq('/users/1') |
| 152 | + expect(router).to receive(:recognize).with(request).and_return('/users/:id(.:format)') |
| 153 | + expect(described_class.route_pattern(request)).to eq('/users/:id') |
148 | 154 | end |
149 | 155 | end |
150 | 156 | end |
|
0 commit comments