From cf5d964133437d44ba13a72ee1a8a21ea67c57fb Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 27 Oct 2021 17:01:49 +0100 Subject: [PATCH] Update usages of old preference getters and setters --- app/mailers/producer_mailer.rb | 2 +- app/serializers/api/admin/enterprise_serializer.rb | 2 +- app/services/order_data_masker.rb | 2 +- app/services/permitted_attributes/enterprise.rb | 2 +- .../admin/enterprises/form/_shop_preferences.html.haml | 8 ++++---- spec/controllers/admin/enterprises_controller_spec.rb | 4 ++-- .../orders_and_fulfillments_report_spec.rb | 4 ++-- spec/lib/open_food_network/packing_report_spec.rb | 4 ++-- spec/mailers/producer_mailer_spec.rb | 8 ++++---- spec/services/order_data_masker_spec.rb | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/mailers/producer_mailer.rb b/app/mailers/producer_mailer.rb index 4a22ef801d..b0abc8209e 100644 --- a/app/mailers/producer_mailer.rb +++ b/app/mailers/producer_mailer.rb @@ -77,7 +77,7 @@ class ProducerMailer < Spree::BaseMailer end def set_customer_data(line_items) - return unless @coordinator.preferred_show_customer_names_to_suppliers + return unless @coordinator.show_customer_names_to_suppliers? line_items.map do |line_item| { diff --git a/app/serializers/api/admin/enterprise_serializer.rb b/app/serializers/api/admin/enterprise_serializer.rb index 6d45133e4c..75ffeeee55 100644 --- a/app/serializers/api/admin/enterprise_serializer.rb +++ b/app/serializers/api/admin/enterprise_serializer.rb @@ -8,7 +8,7 @@ module Api :long_description, :preferred_product_selection_from_inventory_only, :preferred_shopfront_message, :preferred_shopfront_closed_message, :preferred_shopfront_taxon_order, :preferred_shopfront_producer_order, - :preferred_shopfront_order_cycle_order, :preferred_show_customer_names_to_suppliers, + :preferred_shopfront_order_cycle_order, :show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method, :owner, :contact, :users, :tag_groups, :default_tag_group, :require_login, :allow_guest_orders, :allow_order_changes, :logo, :promo_image, :terms_and_conditions, diff --git a/app/services/order_data_masker.rb b/app/services/order_data_masker.rb index 0cca1c91d2..e5ae198332 100644 --- a/app/services/order_data_masker.rb +++ b/app/services/order_data_masker.rb @@ -15,7 +15,7 @@ class OrderDataMasker attr_accessor :order def customer_names_allowed? - order.distributor.preferences[:show_customer_names_to_suppliers] + order.distributor.show_customer_names_to_suppliers end def mask_customer_names diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index dbae9dee32..6838448fb8 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -32,7 +32,7 @@ module PermittedAttributes :preferred_product_selection_from_inventory_only, :preferred_shopfront_message, :preferred_shopfront_closed_message, :preferred_shopfront_taxon_order, :preferred_shopfront_producer_order, :preferred_shopfront_order_cycle_order, - :preferred_show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method, + :show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method, ] end end diff --git a/app/views/admin/enterprises/form/_shop_preferences.html.haml b/app/views/admin/enterprises/form/_shop_preferences.html.haml index 527c85db1b..b10914bdff 100644 --- a/app/views/admin/enterprises/form/_shop_preferences.html.haml +++ b/app/views/admin/enterprises/form/_shop_preferences.html.haml @@ -103,8 +103,8 @@ %div{'ofn-with-tip' => t('.customer_names_tip')} %a= t 'admin.whats_this' .three.columns - = radio_button :enterprise, :preferred_show_customer_names_to_suppliers, true - = label :enterprise_preferred_show_customer_names_to_suppliers, t('.customer_names_true'), value: :true + = radio_button :enterprise, :show_customer_names_to_suppliers, true + = label :enterprise_show_customer_names_to_suppliers, t('.customer_names_true'), value: :true .five.columns.omega - = radio_button :enterprise, :preferred_show_customer_names_to_suppliers, false - = label :enterprise_preferred_show_customer_names_to_suppliers, t('.customer_names_false'), value: :false + = radio_button :enterprise, :show_customer_names_to_suppliers, false + = label :enterprise_show_customer_names_to_suppliers, t('.customer_names_false'), value: :false diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index d8b2e4f781..00bd934860 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -165,11 +165,11 @@ describe Admin::EnterprisesController, type: :controller do it "updates enterprise preferences" do allow(controller).to receive_messages spree_current_user: distributor_manager update_params = { id: distributor, - enterprise: { preferred_show_customer_names_to_suppliers: "1" } } + enterprise: { show_customer_names_to_suppliers: "1" } } spree_post :update, update_params distributor.reload - expect(distributor.preferences[:show_customer_names_to_suppliers]).to eq true + expect(distributor.show_customer_names_to_suppliers).to eq true end describe "enterprise properties" do diff --git a/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb b/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb index b87d872a0e..51343ddcab 100644 --- a/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb +++ b/spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb @@ -82,7 +82,7 @@ describe OpenFoodNetwork::OrdersAndFulfillmentsReport do context "where the distributor allows suppliers to see customer names" do before do - distributor.preferred_show_customer_names_to_suppliers = true + distributor.update_columns show_customer_names_to_suppliers: true end it "shows line items supplied by my producers, with names shown" do @@ -117,7 +117,7 @@ describe OpenFoodNetwork::OrdersAndFulfillmentsReport do context "where the distributor allows suppliers to see customer names" do before do - distributor.preferred_show_customer_names_to_suppliers = true + distributor.show_customer_names_to_suppliers = true end it "does not show line items supplied by my producers" do diff --git a/spec/lib/open_food_network/packing_report_spec.rb b/spec/lib/open_food_network/packing_report_spec.rb index 587f6d2d2a..baa282826b 100644 --- a/spec/lib/open_food_network/packing_report_spec.rb +++ b/spec/lib/open_food_network/packing_report_spec.rb @@ -66,7 +66,7 @@ module OpenFoodNetwork context "where the distributor allows suppliers to see customer names" do before do - distributor.preferred_show_customer_names_to_suppliers = true + distributor.update_columns show_customer_names_to_suppliers: true end it "shows line items supplied by my producers, with names shown" do @@ -96,7 +96,7 @@ module OpenFoodNetwork context "where the distributor allows suppliers to see customer names" do before do - distributor.preferred_show_customer_names_to_suppliers = true + distributor.show_customer_names_to_suppliers = true end it "does not show line items supplied by my producers" do diff --git a/spec/mailers/producer_mailer_spec.rb b/spec/mailers/producer_mailer_spec.rb index ad1480c754..6437b921a3 100644 --- a/spec/mailers/producer_mailer_spec.rb +++ b/spec/mailers/producer_mailer_spec.rb @@ -128,9 +128,9 @@ describe ProducerMailer, type: :mailer do expect(mail.body.encoded).to include(p1.name) end - context 'when flag preferred_show_customer_names_to_suppliers is true' do + context 'when flag show_customer_names_to_suppliers is true' do before do - order_cycle.coordinator.set_preference(:show_customer_names_to_suppliers, true) + order_cycle.coordinator.show_customer_names_to_suppliers = true end it "adds customer names table" do @@ -160,9 +160,9 @@ describe ProducerMailer, type: :mailer do end end - context 'when flag preferred_show_customer_names_to_suppliers is false' do + context 'when flag show_customer_names_to_suppliers is false' do before do - order_cycle.coordinator.set_preference(:show_customer_names_to_suppliers, false) + order_cycle.coordinator.show_customer_names_to_suppliers = false end it "does not add customer names table" do diff --git a/spec/services/order_data_masker_spec.rb b/spec/services/order_data_masker_spec.rb index 9c98f967e2..edbbad930b 100644 --- a/spec/services/order_data_masker_spec.rb +++ b/spec/services/order_data_masker_spec.rb @@ -8,7 +8,7 @@ describe OrderDataMasker do let(:order) { create(:order, distributor: distributor, ship_address: create(:address)) } context 'when displaying customer names is allowed' do - before { distributor.preferences[:show_customer_names_to_suppliers] = true } + before { distributor.show_customer_names_to_suppliers = true } it 'masks personal addresses and email' do described_class.new(order).call @@ -49,7 +49,7 @@ describe OrderDataMasker do end context 'when displaying customer names is not allowed' do - before { distributor.preferences[:show_customer_names_to_suppliers] = false } + before { distributor.show_customer_names_to_suppliers = false } it 'masks personal addresses and email' do described_class.new(order).call