diff --git a/app/services/permitted_attributes/order_cycle.rb b/app/services/permitted_attributes/order_cycle.rb index 1a7c9047b3..dd74607168 100644 --- a/app/services/permitted_attributes/order_cycle.rb +++ b/app/services/permitted_attributes/order_cycle.rb @@ -16,6 +16,7 @@ module PermittedAttributes [ :name, :orders_open_at, :orders_close_at, :coordinator_id, :preferred_product_selection_from_coordinator_inventory_only, + :automatic_notifications, { schedule_ids: [], coordinator_fee_ids: [] } ] end diff --git a/app/views/admin/order_cycles/_advanced_settings.html.haml b/app/views/admin/order_cycles/_advanced_settings.html.haml index bfbd6e9c91..013af8ee33 100644 --- a/app/views/admin/order_cycles/_advanced_settings.html.haml +++ b/app/views/admin/order_cycles/_advanced_settings.html.haml @@ -15,6 +15,14 @@ = f.radio_button :preferred_product_selection_from_coordinator_inventory_only, false = f.label :preferred_product_selection_from_coordinator_inventory_only, t('.preferred_product_selection_from_coordinator_inventory_only_all') + .row + .alpha.three.columns + = f.label :automatic_notifications, t('.automatic_notifications') + .with-tip{ 'data-powertip' => t('.automatic_notifications_tip') } + %a= t('admin.whats_this') + .omega.eight.columns + = f.check_box :automatic_notifications + .row .sixteen.columns.alpha.omega.text-center %input{ type: 'submit', value: t('.save_reload') } diff --git a/config/locales/en.yml b/config/locales/en.yml index bff8d76dec..a8f201c096 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1078,6 +1078,8 @@ en: add_supplier: 'Add supplier' add_distributor: 'Add distributor' advanced_settings: + automatic_notifications: Automatic notifications + automatic_notifications_tip: Automatically notify producers with their orders via emails when order cycles close title: Advanced Settings choose_product_tip: You can restrict products incoming and outgoing to only %{inventory}'s inventory. preferred_product_selection_from_coordinator_inventory_only_here: Coordinator's Inventory Only diff --git a/spec/controllers/admin/order_cycles_controller_spec.rb b/spec/controllers/admin/order_cycles_controller_spec.rb index 9f9be23eb5..9ac31eb77a 100644 --- a/spec/controllers/admin/order_cycles_controller_spec.rb +++ b/spec/controllers/admin/order_cycles_controller_spec.rb @@ -216,6 +216,17 @@ module Admin spree_put :update, params. merge(order_cycle: { preferred_product_selection_from_coordinator_inventory_only: true }) end + + it "can update preference automatic_notifications" do + expect(OrderCycleForm).to receive(:new). + with(order_cycle, + { "automatic_notifications" => true }, + anything) { form_mock } + allow(form_mock).to receive(:save) { true } + + spree_put :update, params. + merge(order_cycle: { automatic_notifications: true }) + end end end diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index 3a9fd7006f..dcdcab423e 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -371,7 +371,9 @@ describe OrderCycle do it "clones itself" do coordinator = create(:enterprise); oc = create(:simple_order_cycle, - coordinator_fees: [create(:enterprise_fee, enterprise: coordinator)], preferred_product_selection_from_coordinator_inventory_only: true) + coordinator_fees: [create(:enterprise_fee, enterprise: coordinator)], + preferred_product_selection_from_coordinator_inventory_only: true, + automatic_notifications: true) ex1 = create(:exchange, order_cycle: oc) ex2 = create(:exchange, order_cycle: oc) oc.clone! @@ -382,6 +384,7 @@ describe OrderCycle do expect(occ.orders_close_at).to be_nil 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.coordinator).to eq(oc.coordinator) expect(occ.coordinator_fee_ids).not_to be_empty