blob: 52723ff58230d5e17fcdc4fd1a2f791b1466cbe7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::ArchiveTraceWorker do
describe '#perform' do
subject { described_class.new.perform(job&.id) }
context 'when job is found' do
let(:job) { create(:ci_build, :trace_live) }
it 'executes service' do
allow_next_instance_of(Ci::ArchiveTraceService) do |instance|
allow(instance).to receive(:execute).with(job, anything)
end
subject
end
it 'has preloaded the arguments for archiving' do
allow_next_instance_of(Ci::ArchiveTraceService) do |instance|
allow(instance).to receive(:execute) do |job|
expect(job.association(:project)).to be_loaded
expect(job.association(:pending_state)).to be_loaded
end
end
subject
end
context 'when sticky_ci_archive_trace_worker is disabled' do
before do
stub_feature_flags(sticky_ci_archive_trace_worker: false)
end
it 'does not preload associations' do
allow_next_instance_of(Ci::ArchiveTraceService) do |instance|
allow(instance).to receive(:execute) do |job|
expect(job.association(:project)).not_to be_loaded
expect(job.association(:pending_state)).not_to be_loaded
end
end
subject
end
end
end
context 'when job is not found' do
let(:job) { nil }
it 'does not execute service' do
allow_next_instance_of(Ci::ArchiveTraceService) do |instance|
allow(instance).not_to receive(:execute)
end
subject
end
end
end
end
|