mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Delete StateChanges older than a month
They are useful for troubleshooting but a month data seems enough.
This commit is contained in:
@@ -34,7 +34,7 @@ class TruncateData
|
||||
|
||||
def remove_transient_data
|
||||
Spree::ReturnAuthorization.delete_all
|
||||
Spree::StateChange.delete_all
|
||||
Spree::StateChange.delete_all("created_at < '#{1.month.ago.to_date}'")
|
||||
Spree::LogEntry.delete_all
|
||||
sql_delete_from "sessions"
|
||||
end
|
||||
|
||||
@@ -20,6 +20,14 @@ describe TruncateData do
|
||||
|
||||
expect(OrderCycle.all).to be_empty
|
||||
end
|
||||
|
||||
it 'deletes state changes older than a month' do
|
||||
TruncateData.new.call
|
||||
|
||||
expect(Spree::StateChange)
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when months_to_keep is nil' do
|
||||
@@ -33,6 +41,14 @@ describe TruncateData do
|
||||
|
||||
expect(OrderCycle.all).to be_empty
|
||||
end
|
||||
|
||||
it 'deletes state changes older than a month' do
|
||||
TruncateData.new.call
|
||||
|
||||
expect(Spree::StateChange)
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when months_to_keep is specified' do
|
||||
@@ -50,6 +66,14 @@ describe TruncateData do
|
||||
|
||||
expect(OrderCycle.all).to contain_exactly(recent_order_cycle)
|
||||
end
|
||||
|
||||
it 'deletes state changes older than a month' do
|
||||
TruncateData.new.call
|
||||
|
||||
expect(Spree::StateChange)
|
||||
.to have_received(:delete_all)
|
||||
.with("created_at < '#{1.month.ago.to_date}'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user