diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-10 18:27:49 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-06-13 13:07:23 +0300 |
commit | 1c60ff0b7ae190a5c6c1cc8c72358af6ef66c05e (patch) | |
tree | 8d88c79736e78a21ad3b790ce32a7587b0d7ffc9 /spec/workers/expire_build_artifacts_worker_spec.rb | |
parent | 6013768fec33e3bf084019d97dbfb7cca78f8e82 (diff) |
Test ExpireBuildArtifactsWorker
Diffstat (limited to 'spec/workers/expire_build_artifacts_worker_spec.rb')
-rw-r--r-- | spec/workers/expire_build_artifacts_worker_spec.rb | 55 |
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 |