diff --git a/app/jobs/build_lists/clean_buildroot_job.rb b/app/jobs/build_lists/clean_buildroot_job.rb index f1e8bfceb..90cdfae63 100644 --- a/app/jobs/build_lists/clean_buildroot_job.rb +++ b/app/jobs/build_lists/clean_buildroot_job.rb @@ -6,6 +6,7 @@ module BuildLists def self.perform build_lists = BuildList.where(save_buildroot: true). + for_status(BuildList::BUILD_ERROR). where('updated_at < ?', Time.now - 1.hour). where('results ~ ?', "file_name: #{FILENAME}") diff --git a/spec/jobs/clean_buildroot_job_spec.rb b/spec/jobs/clean_buildroot_job_spec.rb index da4e32785..a1be850a3 100644 --- a/spec/jobs/clean_buildroot_job_spec.rb +++ b/spec/jobs/clean_buildroot_job_spec.rb @@ -6,7 +6,7 @@ describe BuildLists::CleanBuildrootJob do subject { BuildLists::CleanBuildrootJob } it 'ensures that not raises error' do - FactoryGirl.create(:build_list) + FactoryGirl.create(:build_list, status: BuildList::BUILD_ERROR) expect(FileStoreService::File).to_not receive(:new) expect do subject.perform @@ -20,11 +20,13 @@ describe BuildLists::CleanBuildrootJob do ] FactoryGirl.create(:build_list, results: results, - save_buildroot: true + save_buildroot: true, + status: BuildList::BUILD_ERROR ) bl = FactoryGirl.create(:build_list, results: results, save_buildroot: true, + status: BuildList::BUILD_ERROR, updated_at: Time.now - 2.hours ) file_store_service = double(:file_store_service, destroy: true)