Merge pull request #12014 from mkllnk/voucher-on

Remove feature toggle for vouchers, they are always on
This commit is contained in:
David Cook
2024-01-10 09:58:35 +11:00
committed by GitHub
13 changed files with 33 additions and 50 deletions

View File

@@ -9,12 +9,6 @@
%fieldset.alpha.no-border-bottom{ id: "#{item[:name]}_panel", data: { "tabs-and-panels-target": "panel" }}
%legend= t(".#{ item[:name] }.legend")
- when 'vouchers'
- if feature?(:vouchers, spree_current_user, @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
- else
%fieldset.alpha.no-border-bottom{ id: "#{item[:name]}_panel", data: { "tabs-and-panels-target": "panel" }}
%legend= t(".#{ item[:form_name] || item[:name] }.legend")

View File

@@ -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, @enterprise))
- next if !item[:show]
%a.menu_item{ href: item[:href] || "##{item[:name]}_panel", data: { action: "tabs-and-panels#activate", "tabs-and-panels-target": "tab", test: "link_for_#{item[:name]}" }, class: item[:selected] }
%i{ class: item[:icon_class] }
%span= t(".enterprise.#{item[:name] }")

View File

@@ -1,5 +1,5 @@
.medium-6#checkout-payment-methods
- if feature?(:vouchers, spree_current_user, @order.distributor) && @order.distributor.vouchers.present?
- if @order.distributor.vouchers.present?
%div.checkout-substep
= render partial: "checkout/voucher_section", locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }

View File

@@ -2,6 +2,9 @@
border-right: 2px solid #f6f6f6;
border-top: 2px solid #f6f6f6;
/* Reserve space for the save bar to avoid hidden menu items. */
margin-bottom: 2em;
.menu_item {
display: block;
padding: 8px 15px;

View File

@@ -40,10 +40,6 @@ module OpenFoodNetwork
shipping categories. Activating this feature for an enterprise owner
will activate it for all shops of this enterprise.
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.
DESC

View File

@@ -105,7 +105,7 @@ describe "Reporting::Reports::SalesTax::SalesTaxTotalsByOrder" do
expect(tax_total).to eq(0.2 + 2)
end
context "with a voucher", feature: :vouchers do
context "with a voucher" do
let(:voucher) do
create(:voucher_flat_rate, code: 'some_code', enterprise: order.distributor, amount: 10)
end
@@ -133,7 +133,7 @@ describe "Reporting::Reports::SalesTax::SalesTaxTotalsByOrder" do
expect(total).to eq(113.3 - 3.3)
end
context "with a voucher", feature: :vouchers do
context "with a voucher" do
let(:voucher) do
create(:voucher_flat_rate, code: 'some_code', enterprise: order.distributor, amount: 10)
end
@@ -214,7 +214,7 @@ describe "Reporting::Reports::SalesTax::SalesTaxTotalsByOrder" do
create(:voucher_flat_rate, code: 'some_code', enterprise: order.distributor, amount: 10)
end
it "adjusts total_excl_tax and tax with voucher tax", feature: :vouchers do
it "adjusts total_excl_tax and tax with voucher tax" do
add_voucher(order, voucher)
mock_voucher_adjustment_service(excluded_tax: -0.29)

View File

@@ -2,7 +2,7 @@
require "spec_helper"
describe "/admin/enterprises/:enterprise_id/vouchers", type: :request, feature: :vouchers do
describe "/admin/enterprises/:enterprise_id/vouchers", type: :request do
let(:enterprise) { create(:supplier_enterprise, name: "Feedme") }
let(:enterprise_user) { create(:user, enterprise_limit: 1) }

View File

@@ -623,9 +623,7 @@ describe '
before do
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
end
it "set the hide_ofn_navigation preference for the current shop" do
@@ -636,9 +634,7 @@ describe '
expect(distributor1.reload.hide_ofn_navigation).to be true
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
uncheck "Hide OFN navigation"
click_button 'Update'
@@ -655,9 +651,7 @@ describe '
expect(distributor1.reload.hide_ofn_navigation).to be true
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
expect(page).to have_content "LOGO USED IN SHOPFRONT"
uncheck "Hide OFN navigation"
@@ -672,9 +666,7 @@ describe '
distributor1.update_attribute(:hide_ofn_navigation, true)
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
end
it "can updload the white label logo for the current shop" do
@@ -694,9 +686,7 @@ describe '
distributor1.update white_label_logo: white_logo_file
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
end
it "can remove the white label logo for the current shop" do
@@ -750,9 +740,7 @@ describe '
expect(distributor1.reload.hide_groups_tab).to be true
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
uncheck "Hide groups tab in shopfront"
click_button 'Update'
@@ -764,9 +752,7 @@ describe '
context "creating custom tabs" do
before do
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
check "Create custom tab in shopfront"
end
@@ -788,9 +774,7 @@ describe '
expect(page).to have_content("Custom tab title can't be blank")
expect(distributor1.reload.custom_tab).to be_nil
within(".side_menu") do
click_link "White Label"
end
select_white_label
expect(page).to have_checked_field "Create custom tab in shopfront"
end
@@ -813,9 +797,7 @@ describe '
before do
distributor1.update(custom_tab:)
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
end
select_white_label
end
it "display the custom tab fields with the current values" do
@@ -1094,6 +1076,14 @@ describe '
end
end
end
def select_white_label
# The savebar sits on top of the bottom menu item until we scroll.
scroll_to :bottom
within(".side_menu") do
click_link "White Label"
end
end
end
def update_message

View File

@@ -20,8 +20,10 @@ describe "Orders And Fulfillment" do
create(:address, address1: "distributor address", city: 'The Shire', zipcode: "1234")
}
let(:distributor) {
create(:distributor_enterprise, address: distributor_address,
name: "Distributor Name")
create(:distributor_enterprise,
with_payment_and_shipping: true,
address: distributor_address,
name: "Distributor Name")
}
let(:order_cycle) { create(:simple_order_cycle, distributors: [distributor]) }
let(:order1) {

View File

@@ -15,8 +15,6 @@ describe '
let(:enterprise_user) { create(:user, enterprise_limit: 1) }
before do
Flipper.enable(:vouchers, enterprise)
enterprise_user.enterprise_roles.build(enterprise:).save
login_as enterprise_user
end

View File

@@ -114,7 +114,7 @@ describe "As a consumer, I want to checkout my order" do
end
end
describe "vouchers", feature: :vouchers do
describe "vouchers" do
context "with no voucher available" do
before do
visit checkout_step_path(:payment)

View File

@@ -108,7 +108,7 @@ describe "As a consumer, I want to see adjustment breakdown" do
assert_db_tax_incl
end
context "when using a voucher", feature: :vouchers do
context "when using a voucher" do
let!(:voucher) do
create(:voucher_flat_rate, code: 'some_code', enterprise: distributor, amount: 10)
end

View File

@@ -2,7 +2,7 @@
require "system_helper"
describe "As a consumer, I want to see adjustment breakdown", feature: :vouchers do
describe "As a consumer, I want to see adjustment breakdown" do
include ShopWorkflow
include CheckoutHelper
include CheckoutRequestsHelper