Update usages of old preference getters and setters

This commit is contained in:
Matt-Yorkley
2021-10-27 17:01:49 +01:00
parent 4f5c266356
commit cf5d964133
10 changed files with 20 additions and 20 deletions

View File

@@ -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|
{

View File

@@ -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,

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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