mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Allow Vouchers feature per enterprise
I also kept the per-user check to be backwards-compatible. Some instances have that enabled already. And for early testing, you may want to test with only one user first before all customer see it.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
%legend= t(".#{ item[:name] }.legend")
|
||||
|
||||
- when 'vouchers'
|
||||
- if feature?(:vouchers, spree_current_user)
|
||||
- if feature?(:vouchers, spree_current_user) || feature?(:vouchers, @enterprise)
|
||||
%fieldset.alpha.no-border-bottom{ id: "#{item[:name]}_panel", data: { "tabs-and-panels-target": "panel" }}
|
||||
%legend= t(".#{ item[:form_name] || item[:name] }.legend")
|
||||
= render "admin/enterprises/form/#{ item[:form_name] || item[:name] }", f: f
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.side_menu#side_menu
|
||||
- if @enterprise
|
||||
- enterprise_side_menu_items(@enterprise).each do |item|
|
||||
- next if !item[:show] || (item[:name] == 'vouchers' && !feature?(:vouchers, spree_current_user))
|
||||
- next if !item[:show] || (item[:name] == 'vouchers' && !(feature?(:vouchers, spree_current_user) || feature?(:vouchers, @enterprise)))
|
||||
%a.menu_item{ href: item[:href] || "##{item[:name]}_panel", id: item[:name], data: { action: "tabs-and-panels#changeActivePanel tabs-and-panels#changeActiveTab", "tabs-and-panels-target": "tab" }, class: item[:selected] }
|
||||
%i{ class: item[:icon_class] }
|
||||
%span= t(".enterprise.#{item[:name] }")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.medium-6#checkout-payment-methods
|
||||
- if feature?(:vouchers, spree_current_user) && @order.distributor.vouchers.present?
|
||||
- if (feature?(:vouchers, spree_current_user) || feature?(:vouchers, @order.distributor)) && @order.distributor.vouchers.present?
|
||||
%div.checkout-substep
|
||||
= render partial: "split_checkout/voucher_section", locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ module OpenFoodNetwork
|
||||
DESC
|
||||
"vouchers" => <<~DESC,
|
||||
Add voucher functionality. Voucher can be managed via Enterprise settings.
|
||||
This is activated per enterprise. Enter actors as <code>Enterprise;1234</code>.
|
||||
DESC
|
||||
"invoices" => <<~DESC,
|
||||
Preserve the state of generated invoices and enable multiple invoice numbers instead of only one live-updating invoice.
|
||||
|
||||
@@ -14,6 +14,15 @@ describe OpenFoodNetwork::FeatureToggle do
|
||||
Flipper.enable(:foo)
|
||||
expect(feature_toggle.enabled?(:foo)).to be true
|
||||
end
|
||||
|
||||
it "can be activated per enterprise" do
|
||||
enterprise = Enterprise.new(id: 5)
|
||||
|
||||
Flipper.enable(:foo, enterprise)
|
||||
|
||||
expect(feature_toggle.enabled?(:foo)).to eq false
|
||||
expect(feature_toggle.enabled?(:foo, enterprise)).to eq true
|
||||
end
|
||||
end
|
||||
|
||||
describe ".setup!" do
|
||||
|
||||
Reference in New Issue
Block a user