Sync when switching from nil dates to open

This commit is contained in:
Matt-Yorkley
2022-02-16 21:45:43 +00:00
parent 5913720c85
commit 00fa84e3b5
2 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -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