blob: eb8afb20275d52b2e9e85f7a66669dd4fcb04d38 (
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
|
require 'spec_helper'
describe ExpireBuildArtifactsWorker do
include RepoHelpers
let(:worker) { described_class.new }
describe '#perform' do
before { build }
subject! { worker.perform }
context 'with expired artifacts' do
let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now - 7.days) }
it 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy
end
end
context 'with not yet expired artifacts' do
let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now + 7.days) }
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_truthy
end
end
context 'without expire date' do
let!(:build) { create(:ci_build, :artifacts) }
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey
end
end
context 'for expired artifacts' do
let!(:build) { create(:ci_build, artifacts_expire_at: Time.now - 7.days) }
it 'does not erase artifacts' do
expect_any_instance_of(Ci::Build).not_to have_received(:erase_artifacts!)
end
it 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy
end
end
end
end
|