diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index f25b676651e..c07832a4b5f 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -472,7 +472,7 @@ describe Ci::Build, models: true do end it 'when assigning invalid duration' do - expect{ build.artifacts_expire_in = '7 elephants' }.not_to raise_error + expect { build.artifacts_expire_in = '7 elephants' }.not_to raise_error is_expected.to be_nil end diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index 616b41eabe0..7e50bea90d1 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -380,7 +380,7 @@ describe Ci::API::API do context 'with an expire_in given' do let(:expire_in) { '7 days' } - it do + it 'updates when specified' do build.reload expect(response.status).to eq(201) expect(json_response['artifacts_expire_at']).not_to be_empty @@ -391,7 +391,7 @@ describe Ci::API::API do context 'with no expire_in given' do let(:expire_in) { nil } - it do + it 'ignores if not specified' do build.reload expect(response.status).to eq(201) expect(json_response['artifacts_expire_at']).to be_nil diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb index 501ca630e55..8168ad98062 100644 --- a/spec/workers/expire_build_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_artifacts_worker_spec.rb @@ -6,14 +6,14 @@ describe ExpireBuildArtifactsWorker do 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 do - expect_any_instance_of(Ci::Build).to receive(:erase_artifacts!) - - worker.perform - + it 'does expire' do expect(build.reload.artifacts_expired?).to be_truthy end end @@ -21,22 +21,16 @@ describe ExpireBuildArtifactsWorker do 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 - - expect(build.reload.artifacts_expired?).to be_falsey + 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 do - expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!) - - worker.perform + it 'does not expire' do + expect(build.reload.artifacts_expired?).to be_falsey end end