mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Add automatic_notification field in advanced settings
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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') }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user