summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-06-10 17:27:49 +0200
committerPhil Hughes <me@iamphill.com>2016-06-13 11:07:23 +0100
commit1c60ff0b7ae190a5c6c1cc8c72358af6ef66c05e (patch)
tree8d88c79736e78a21ad3b790ce32a7587b0d7ffc9 /spec/workers
parent6013768fec33e3bf084019d97dbfb7cca78f8e82 (diff)
downloadgitlab-ce-1c60ff0b7ae190a5c6c1cc8c72358af6ef66c05e.tar.gz
Test ExpireBuildArtifactsWorker
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/expire_build_artifacts_worker_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb
new file mode 100644
index 00000000000..c9ccddc2a09
--- /dev/null
+++ b/spec/workers/expire_build_artifacts_worker_spec.rb
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+describe ExpireBuildArtifactsWorker do
+ include RepoHelpers
+
+ let(:worker) { ExpireBuildArtifactsWorker.new }
+
+ describe '#perform' do
+ context 'with expired artifacts' do
+ let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now - 7.days) }
+
+ it do
+ expect_any_instance_of(Ci::Build).to receive(:erase_artifacts!)
+ worker.perform
+ build.reload
+ expect(build.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 do
+ expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!)
+ worker.perform
+ build.reload
+ expect(build.artifacts_expired?).to be_falsey
+ end
+ end
+
+ context 'without expire date' do
+ let!(:build) { create(:ci_build, :artifacts) }
+
+ it do
+ expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!)
+ worker.perform
+ end
+ end
+
+ context 'for expired artifacts' do
+ let!(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now - 7.days) }
+
+ before do
+ build.erase_artifacts!
+ end
+
+ it do
+ expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!)
+ worker.perform
+ build.reload
+ expect(build.artifacts_expired?).to be_truthy
+ end
+ end
+ end
+end