mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Sync when switching from nil dates to open
This commit is contained in:
@@ -280,7 +280,7 @@ class OrderCycle < ApplicationRecord
|
||||
end
|
||||
|
||||
def was_closed?
|
||||
orders_close_at_previously_was && Time.zone.now > orders_close_at_previously_was
|
||||
orders_close_at_previously_was.blank? || Time.zone.now > orders_close_at_previously_was
|
||||
end
|
||||
|
||||
def sync_subscriptions
|
||||
|
||||
@@ -572,6 +572,18 @@ describe OrderCycle do
|
||||
oc.update(orders_open_at: 1.day.from_now, orders_close_at: 1.week.from_now)
|
||||
}.to change{ ProxyOrder.count }
|
||||
end
|
||||
|
||||
context "when the current dates are nil" do
|
||||
before { oc.update(orders_open_at: nil, orders_close_at: nil) }
|
||||
|
||||
it "syncs subscriptions when transitioning from closed to open" do
|
||||
expect(OrderManagement::Subscriptions::ProxyOrderSyncer).to receive(:new).and_call_original
|
||||
|
||||
expect{
|
||||
oc.update(orders_open_at: 1.day.ago, orders_close_at: 1.week.from_now)
|
||||
}.to change{ ProxyOrder.count }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "processed_at " do
|
||||
|
||||
Reference in New Issue
Block a user