Merge pull request #7613 from betagouv/fix-export-purge-stale-scope
fix(export): fix PurgeStaledExportsJob regression with `stale` scope
This commit is contained in:
commit
5fd44208d3
2 changed files with 4 additions and 4 deletions
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue