From 9be37b0aaac784caa0022020c7ba1ce4556061b2 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 12 Jan 2022 10:55:06 +0000 Subject: [PATCH] Reset flags when cloning an OC --- app/models/order_cycle.rb | 2 +- spec/models/order_cycle_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 6de50ddc7f..2d2c14dbe5 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -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 diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index 19a94492ed..0a36ca7459 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -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