Reset flags when cloning an OC

This commit is contained in:
Matt-Yorkley
2022-01-12 10:55:06 +00:00
parent 54e1a8807a
commit 9be37b0aaa
2 changed files with 4 additions and 2 deletions

View File

@@ -151,7 +151,7 @@ class OrderCycle < ApplicationRecord
def clone!
oc = dup
oc.name = I18n.t("models.order_cycle.cloned_order_cycle_name", order_cycle: oc.name)
oc.orders_open_at = oc.orders_close_at = nil
oc.orders_open_at = oc.orders_close_at = oc.mails_sent = oc.processed_at = nil
oc.coordinator_fee_ids = coordinator_fee_ids
# rubocop:disable Layout/LineLength
oc.preferred_product_selection_from_coordinator_inventory_only = preferred_product_selection_from_coordinator_inventory_only

View File

@@ -373,7 +373,7 @@ describe OrderCycle do
oc = create(:simple_order_cycle,
coordinator_fees: [create(:enterprise_fee, enterprise: coordinator)],
preferred_product_selection_from_coordinator_inventory_only: true,
automatic_notifications: true)
automatic_notifications: true, processed_at: Time.zone.now, mails_sent: true)
ex1 = create(:exchange, order_cycle: oc)
ex2 = create(:exchange, order_cycle: oc)
oc.clone!
@@ -385,6 +385,8 @@ describe OrderCycle do
expect(occ.coordinator).not_to be_nil
expect(occ.preferred_product_selection_from_coordinator_inventory_only).to be true
expect(occ.automatic_notifications).to eq(oc.automatic_notifications)
expect(occ.processed_at).to eq(nil)
expect(occ.mails_sent).to eq(nil)
expect(occ.coordinator).to eq(oc.coordinator)
expect(occ.coordinator_fee_ids).not_to be_empty