Merge pull request #7613 from betagouv/fix-export-purge-stale-scope

fix(export): fix PurgeStaledExportsJob regression with `stale` scope
This commit is contained in:
Colin Darie 2022-07-26 14:31:33 +02:00 committed by GitHub
commit 5fd44208d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -47,8 +47,6 @@ class Export < ApplicationRecord
validates :format, :groupe_instructeurs, :key, presence: true
scope :stale, -> { where('exports.updated_at < ?', (Time.zone.now - MAX_DUREE_CONSERVATION_EXPORT)) }
after_create_commit :compute_async
FORMATS_WITH_TIME_SPAN = [:xlsx, :ods, :csv].flat_map do |format|

View file

@ -24,9 +24,11 @@ RSpec.describe Export, type: :model do
describe '.stale' do
let!(:export) { create(:export) }
let(:stale_date) { Time.zone.now() - (Export::MAX_DUREE_CONSERVATION_EXPORT + 1.minute) }
let!(:stale_export) { create(:export, updated_at: stale_date) }
let!(:stale_export_generated) { create(:export, :generated, updated_at: stale_date) }
let!(:stale_export_failed) { create(:export, :failed, updated_at: stale_date) }
let!(:stale_export_pending) { create(:export, :pending, updated_at: stale_date) }
it { expect(Export.stale).to match_array([stale_export]) }
it { expect(Export.stale(Export::MAX_DUREE_CONSERVATION_EXPORT)).to match_array([stale_export_generated, stale_export_failed]) }
end
describe '.destroy' do