From 6b1e16cf6a5b3d6c55263a146e7f7801ad2852f4 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 29 Sep 2014 21:55:51 +0400 Subject: [PATCH] Added extra condition for BuildLists::CleanBuildrootJob --- app/jobs/build_lists/clean_buildroot_job.rb | 1 + spec/jobs/clean_buildroot_job_spec.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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)