|
14 | 14 | end |
15 | 15 |
|
16 | 16 | it "records the upload event" do |
| 17 | + # make sure AnalyzeJob will be executed immediately |
| 18 | + ActiveStorage::AnalyzeJob.queue_adapter.perform_enqueued_jobs = true |
| 19 | + |
17 | 20 | p = Post.create! |
18 | 21 | get "/posts/#{p.id}/attach" |
19 | 22 |
|
20 | 23 | expect(response).to have_http_status(:ok) |
21 | | - transport.events.each { |e| pp e } # TODO: Remove it once this test is not flaky anymore |
22 | | - expect(transport.events.count).to eq(1) |
| 24 | + expect(transport.events.count).to eq(2) |
| 25 | + |
| 26 | + analysis_transaction = transport.events.first.to_hash |
| 27 | + expect(analysis_transaction[:type]).to eq("transaction") |
| 28 | + expect(analysis_transaction[:spans].count).to eq(1) |
| 29 | + span = analysis_transaction[:spans][0] |
| 30 | + expect(span[:op]).to eq("service_streaming_download.active_storage") |
23 | 31 |
|
24 | | - transaction = transport.events.first.to_hash |
25 | | - expect(transaction[:type]).to eq("transaction") |
26 | | - expect(transaction[:spans].count).to eq(1) |
| 32 | + request_transaction = transport.events.last.to_hash |
| 33 | + expect(request_transaction[:type]).to eq("transaction") |
| 34 | + expect(request_transaction[:spans].count).to eq(1) |
27 | 35 |
|
28 | | - span = transaction[:spans][0] |
| 36 | + span = request_transaction[:spans][0] |
29 | 37 | expect(span[:op]).to eq("service_upload.active_storage") |
30 | 38 | expect(span[:description]).to eq("Disk") |
31 | 39 | expect(span.dig(:data, :key)).to eq(p.cover.key) |
32 | | - expect(span[:trace_id]).to eq(transaction.dig(:contexts, :trace, :trace_id)) |
| 40 | + expect(span[:trace_id]).to eq(request_transaction.dig(:contexts, :trace, :trace_id)) |
33 | 41 | end |
34 | 42 | end |
35 | 43 |
|
|
0 commit comments