mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Do not use a preference, but create a new column for hide_ofn_navigation
This commit is contained in:
committed by
David Cook
parent
dd9fec58a4
commit
89036db666
@@ -9,6 +9,6 @@ module WhiteLabel
|
||||
|
||||
# if the distributor has the hide_ofn_navigation preference set to true
|
||||
# then we should hide the OFN navigation
|
||||
@hide_ofn_navigation = distributor.preferred_hide_ofn_navigation
|
||||
@hide_ofn_navigation = distributor.hide_ofn_navigation
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,6 @@ class Enterprise < ApplicationRecord
|
||||
preference :shopfront_product_sorting_method, :string, default: "by_category"
|
||||
preference :invoice_order_by_supplier, :boolean, default: false
|
||||
preference :product_low_stock_display, :boolean, default: false
|
||||
preference :hide_ofn_navigation, :boolean, default: false
|
||||
|
||||
# Allow hubs to restrict visible variants to only those in their inventory
|
||||
preference :product_selection_from_inventory_only, :boolean, default: false
|
||||
|
||||
@@ -14,7 +14,7 @@ module Api
|
||||
:logo, :promo_image, :terms_and_conditions,
|
||||
:terms_and_conditions_file_name, :terms_and_conditions_updated_at,
|
||||
:preferred_invoice_order_by_supplier, :preferred_product_low_stock_display,
|
||||
:visible, :preferred_hide_ofn_navigation
|
||||
:visible, :hide_ofn_navigation
|
||||
|
||||
has_one :owner, serializer: Api::Admin::UserSerializer
|
||||
has_many :users, serializer: Api::Admin::UserSerializer
|
||||
|
||||
@@ -10,7 +10,7 @@ module Api
|
||||
:phone, :whatsapp_phone, :whatsapp_url, :visible, :email_address, :hash, :logo,
|
||||
:promo_image, :path, :category, :active, :producers, :orders_close_at, :hubs,
|
||||
:taxons, :supplied_taxons, :pickup, :delivery, :preferred_product_low_stock_display,
|
||||
:preferred_hide_ofn_navigation
|
||||
:hide_ofn_navigation
|
||||
|
||||
has_one :address, serializer: Api::AddressSerializer
|
||||
has_many :supplied_properties, serializer: Api::PropertySerializer
|
||||
|
||||
@@ -35,7 +35,7 @@ module PermittedAttributes
|
||||
:show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method,
|
||||
:preferred_invoice_order_by_supplier,
|
||||
:preferred_product_low_stock_display,
|
||||
:preferred_hide_ofn_navigation
|
||||
:hide_ofn_navigation
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :preferred_hide_ofn_navigation, t('.hide_ofn_navigation')
|
||||
= f.label :hide_ofn_navigation, t('.hide_ofn_navigation')
|
||||
.three.columns
|
||||
= f.check_box :preferred_hide_ofn_navigation
|
||||
= f.check_box :hide_ofn_navigation
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddHideOfnNavigationToEnterprises < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :enterprises, :hide_ofn_navigation, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_03_15_031807) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_03_29_080357) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
enable_extension "plpgsql"
|
||||
@@ -224,6 +224,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_15_031807) do
|
||||
t.boolean "show_customer_names_to_suppliers", default: false, null: false
|
||||
t.string "visible", limit: 255, default: "public", null: false
|
||||
t.string "whatsapp_phone", limit: 255
|
||||
t.boolean "hide_ofn_navigation", default: false, null: false
|
||||
t.index ["address_id"], name: "index_enterprises_on_address_id"
|
||||
t.index ["is_primary_producer", "sells"], name: "index_enterprises_on_is_primary_producer_and_sells"
|
||||
t.index ["name"], name: "index_enterprises_on_name", unique: true
|
||||
|
||||
@@ -91,7 +91,7 @@ describe Spree::OrdersController, type: :controller do
|
||||
|
||||
it "redirects to shop when order is empty" do
|
||||
allow(controller).to receive(:current_distributor).and_return(distributor)
|
||||
allow(distributor).to receive(:preferred_hide_ofn_navigation).and_return false
|
||||
allow(distributor).to receive(:hide_ofn_navigation).and_return false
|
||||
allow(controller).to receive(:current_order_cycle).and_return(order_cycle)
|
||||
allow(controller).to receive(:current_order).and_return order
|
||||
allow(order).to receive_message_chain(:line_items, :empty?).and_return true
|
||||
|
||||
@@ -600,7 +600,7 @@ describe '
|
||||
check "Hide OFN navigation"
|
||||
click_button 'Update'
|
||||
expect(flash_message).to eq('Enterprise "First Distributor" has been successfully updated!')
|
||||
expect(distributor1.reload.preferred_hide_ofn_navigation).to be true
|
||||
expect(distributor1.reload.hide_ofn_navigation).to be true
|
||||
|
||||
visit edit_admin_enterprise_path(distributor1)
|
||||
within(".side_menu") do
|
||||
@@ -610,7 +610,7 @@ describe '
|
||||
uncheck "Hide OFN navigation"
|
||||
click_button 'Update'
|
||||
expect(flash_message).to eq('Enterprise "First Distributor" has been successfully updated!')
|
||||
expect(distributor1.reload.preferred_hide_ofn_navigation).to be false
|
||||
expect(distributor1.reload.hide_ofn_navigation).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ describe 'White label setting' do
|
||||
context "manage the hide_ofn_navigation preference" do
|
||||
context "when the preference is set to true" do
|
||||
before do
|
||||
distributor.update_attribute(:preferred_hide_ofn_navigation, true)
|
||||
distributor.update_attribute(:hide_ofn_navigation, true)
|
||||
end
|
||||
|
||||
shared_examples "hides the OFN navigation when needed only" do
|
||||
@@ -132,7 +132,7 @@ describe 'White label setting' do
|
||||
context "when the user has a current distributor that is not the distributor's order" do
|
||||
let!(:another_distributor) { create(:distributor_enterprise) }
|
||||
before do
|
||||
another_distributor.update_attribute(:preferred_hide_ofn_navigation, false)
|
||||
another_distributor.update_attribute(:hide_ofn_navigation, false)
|
||||
allow_any_instance_of(EnterprisesHelper).to receive(:current_distributor).
|
||||
and_return(another_distributor)
|
||||
end
|
||||
@@ -153,7 +153,7 @@ describe 'White label setting' do
|
||||
|
||||
context "when the preference is set to false" do
|
||||
before do
|
||||
distributor.update_attribute(:preferred_hide_ofn_navigation, false)
|
||||
distributor.update_attribute(:hide_ofn_navigation, false)
|
||||
set_order(order)
|
||||
allow_any_instance_of(EnterprisesHelper).to receive(:current_distributor).
|
||||
and_return(distributor)
|
||||
|
||||
Reference in New Issue
Block a user