mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Reset flags when cloning an OC
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user