diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index eff2a6ac1a..dcaae1a149 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -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") diff --git a/app/views/admin/shared/_side_menu.html.haml b/app/views/admin/shared/_side_menu.html.haml index 168add17ce..e900c233a8 100644 --- a/app/views/admin/shared/_side_menu.html.haml +++ b/app/views/admin/shared/_side_menu.html.haml @@ -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] }") diff --git a/app/views/checkout/_payment.html.haml b/app/views/checkout/_payment.html.haml index 38e237bb4d..656a246efe 100644 --- a/app/views/checkout/_payment.html.haml +++ b/app/views/checkout/_payment.html.haml @@ -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 } diff --git a/app/webpacker/css/admin/side_menu.scss b/app/webpacker/css/admin/side_menu.scss index 398787b7b8..f746c45cda 100644 --- a/app/webpacker/css/admin/side_menu.scss +++ b/app/webpacker/css/admin/side_menu.scss @@ -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; diff --git a/lib/open_food_network/feature_toggle.rb b/lib/open_food_network/feature_toggle.rb index feb89bb597..ef23b78a96 100644 --- a/lib/open_food_network/feature_toggle.rb +++ b/lib/open_food_network/feature_toggle.rb @@ -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 Enterprise;1234. - DESC "invoices" => <<~DESC, Preserve the state of generated invoices and enable multiple invoice numbers instead of only one live-updating invoice. DESC diff --git a/spec/lib/reports/sales_tax_totals_by_order_spec.rb b/spec/lib/reports/sales_tax_totals_by_order_spec.rb index 83b46555df..9194ae3dbb 100644 --- a/spec/lib/reports/sales_tax_totals_by_order_spec.rb +++ b/spec/lib/reports/sales_tax_totals_by_order_spec.rb @@ -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) diff --git a/spec/requests/admin/vouchers_spec.rb b/spec/requests/admin/vouchers_spec.rb index 8ec34f28a1..7c77f9a1ff 100644 --- a/spec/requests/admin/vouchers_spec.rb +++ b/spec/requests/admin/vouchers_spec.rb @@ -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) } diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index a70ed7084a..69c52cf6b1 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -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 diff --git a/spec/system/admin/reports/orders_and_fulfillment_spec.rb b/spec/system/admin/reports/orders_and_fulfillment_spec.rb index 2f89ddb6ac..f96ddf89d5 100644 --- a/spec/system/admin/reports/orders_and_fulfillment_spec.rb +++ b/spec/system/admin/reports/orders_and_fulfillment_spec.rb @@ -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) { diff --git a/spec/system/admin/vouchers_spec.rb b/spec/system/admin/vouchers_spec.rb index 0b97755804..c6893de80f 100644 --- a/spec/system/admin/vouchers_spec.rb +++ b/spec/system/admin/vouchers_spec.rb @@ -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 diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index 65f18d271b..970c9a09c8 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -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) diff --git a/spec/system/consumer/checkout/tax_incl_spec.rb b/spec/system/consumer/checkout/tax_incl_spec.rb index dfc9bd9413..e0d1713a1d 100644 --- a/spec/system/consumer/checkout/tax_incl_spec.rb +++ b/spec/system/consumer/checkout/tax_incl_spec.rb @@ -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 diff --git a/spec/system/consumer/checkout/tax_not_incl_spec.rb b/spec/system/consumer/checkout/tax_not_incl_spec.rb index aa44094b71..aa746adad6 100644 --- a/spec/system/consumer/checkout/tax_not_incl_spec.rb +++ b/spec/system/consumer/checkout/tax_not_incl_spec.rb @@ -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