diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3efe519c0..30998d7e4b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -872,39 +872,6 @@ Style/ReturnNilInPredicateMethodDefinition: - 'app/serializers/api/admin/customer_serializer.rb' - 'engines/order_management/app/services/order_management/subscriptions/validator.rb' -# Offense count: 207 -Style/Send: - Exclude: - - 'spec/controllers/admin/subscriptions_controller_spec.rb' - - 'spec/controllers/payment_gateways/paypal_controller_spec.rb' - - 'spec/controllers/spree/admin/base_controller_spec.rb' - - 'spec/controllers/spree/orders_controller_spec.rb' - - 'spec/helpers/order_cycles_helper_spec.rb' - - 'spec/jobs/subscription_confirm_job_spec.rb' - - 'spec/jobs/subscription_placement_job_spec.rb' - - 'spec/lib/open_food_network/address_finder_spec.rb' - - 'spec/lib/open_food_network/enterprise_fee_applicator_spec.rb' - - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - - 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb' - - 'spec/lib/open_food_network/permissions_spec.rb' - - 'spec/lib/open_food_network/tag_rule_applicator_spec.rb' - - 'spec/lib/reports/xero_invoices_report_spec.rb' - - 'spec/lib/stripe/webhook_handler_spec.rb' - - 'spec/models/calculator/weight_spec.rb' - - 'spec/models/enterprise_spec.rb' - - 'spec/models/exchange_spec.rb' - - 'spec/models/spree/order_inventory_spec.rb' - - 'spec/models/spree/payment_spec.rb' - - 'spec/models/spree/return_authorization_spec.rb' - - 'spec/models/tag_rule/filter_order_cycles_spec.rb' - - 'spec/models/tag_rule/filter_payment_methods_spec.rb' - - 'spec/models/tag_rule/filter_products_spec.rb' - - 'spec/models/tag_rule/filter_shipping_methods_spec.rb' - - 'spec/services/cart_service_spec.rb' - - 'spec/services/products_renderer_spec.rb' - - 'spec/services/variant_units/option_value_namer_spec.rb' - - 'spec/support/localized_number_helper.rb' - # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: diff --git a/spec/controllers/admin/subscriptions_controller_spec.rb b/spec/controllers/admin/subscriptions_controller_spec.rb index a59001731a..b60052d8a3 100644 --- a/spec/controllers/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/admin/subscriptions_controller_spec.rb @@ -754,7 +754,7 @@ RSpec.describe Admin::SubscriptionsController, type: :controller do end it "assigns data to instance variables" do - controller.send(:load_form_data) + controller.__send__(:load_form_data) expect(assigns(:customers)).to include customer1, customer2 expect(assigns(:schedules)).to eq [schedule] expect(assigns(:order_cycles)).to eq [order_cycle] @@ -769,7 +769,7 @@ RSpec.describe Admin::SubscriptionsController, type: :controller do } it "only loads Stripe and Cash payment methods" do - controller.send(:load_form_data) + controller.__send__(:load_form_data) expect(assigns(:payment_methods)).to include payment_method, stripe expect(assigns(:payment_methods)).not_to include paypal end diff --git a/spec/controllers/payment_gateways/paypal_controller_spec.rb b/spec/controllers/payment_gateways/paypal_controller_spec.rb index 8eb2fb2191..4670a69bc1 100644 --- a/spec/controllers/payment_gateways/paypal_controller_spec.rb +++ b/spec/controllers/payment_gateways/paypal_controller_spec.rb @@ -109,11 +109,11 @@ module PaymentGateways describe '#expire_current_order' do it 'empties the order_id of the session' do expect(session).to receive(:[]=).with(:order_id, nil) - controller.send(:expire_current_order) + controller.__send__(:expire_current_order) end it 'resets the @current_order ivar' do - controller.send(:expire_current_order) + controller.__send__(:expire_current_order) expect(controller.instance_variable_get(:@current_order)).to be_nil end end diff --git a/spec/controllers/spree/admin/base_controller_spec.rb b/spec/controllers/spree/admin/base_controller_spec.rb index 63844e9883..7879b62d0b 100644 --- a/spec/controllers/spree/admin/base_controller_spec.rb +++ b/spec/controllers/spree/admin/base_controller_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Spree::Admin::BaseController, type: :controller do it "passes a prefix to the serializer method and renders with serializer" do expect(controller).to receive(:serializer).with(prefix) { "SerializerClass" } expect(controller).to receive(:render).with({ json: data, serializer: "SerializerClass" }) - controller.send(:render_as_json, data, ams_prefix: prefix) + controller.__send__(:render_as_json, data, ams_prefix: prefix) end end @@ -35,7 +35,7 @@ RSpec.describe Spree::Admin::BaseController, type: :controller do it "does not pass a prefix to the serializer method and renders with serializer" do expect(controller).to receive(:serializer).with(prefix) { "SerializerClass" } expect(controller).to receive(:render).with({ json: data, serializer: "SerializerClass" }) - controller.send(:render_as_json, data, ams_prefix: prefix) + controller.__send__(:render_as_json, data, ams_prefix: prefix) end end end @@ -51,7 +51,7 @@ RSpec.describe Spree::Admin::BaseController, type: :controller do expect(controller).to receive(:render).with( { json: data, each_serializer: "SerializerClass" } ) - controller.send(:render_as_json, data, ams_prefix: prefix) + controller.__send__(:render_as_json, data, ams_prefix: prefix) end end @@ -63,7 +63,7 @@ RSpec.describe Spree::Admin::BaseController, type: :controller do expect(controller).to receive(:render).with( { json: data, each_serializer: "SerializerClass" } ) - controller.send(:render_as_json, data, ams_prefix: prefix) + controller.__send__(:render_as_json, data, ams_prefix: prefix) end end end @@ -79,21 +79,22 @@ RSpec.describe Spree::Admin::BaseController, type: :controller do context "when a prefix is passed in" do context "and the prefix appears in the whitelist" do it "returns the requested serializer" do - expect(controller.send(:serializer, - 'allowed_prefix')).to eq Api::Admin::AllowedPrefixBaseSerializer + expect( + controller.__send__(:serializer, 'allowed_prefix') + ).to eq Api::Admin::AllowedPrefixBaseSerializer end end context "and the prefix does not appear in the whitelist" do it "raises an error" do - expect{ controller.send(:serializer, 'other_prefix') }.to raise_error RuntimeError + expect{ controller.__send__(:serializer, 'other_prefix') }.to raise_error RuntimeError end end end context "when no prefix is passed in" do it "returns the default serializer" do - expect(controller.send(:serializer, nil)).to eq Api::Admin::BaseSerializer + expect(controller.__send__(:serializer, nil)).to eq Api::Admin::BaseSerializer end end end diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb index e4eeb84b8c..de7f435d7e 100644 --- a/spec/controllers/spree/orders_controller_spec.rb +++ b/spec/controllers/spree/orders_controller_spec.rb @@ -389,7 +389,7 @@ RSpec.describe Spree::OrdersController, type: :controller do context "when no order id is given in params" do it "returns the current_order" do - expect(controller.send(:order_to_update)).to eq current_order + expect(controller.__send__(:order_to_update)).to eq current_order end end @@ -402,7 +402,7 @@ RSpec.describe Spree::OrdersController, type: :controller do let!(:order) { create(:order) } it "returns nil" do - expect(controller.send(:order_to_update)).to eq nil + expect(controller.__send__(:order_to_update)).to eq nil end end @@ -413,7 +413,7 @@ RSpec.describe Spree::OrdersController, type: :controller do before { allow(controller).to receive(:can?).with(:update, order) { false } } it "returns nil" do - expect(controller.send(:order_to_update)).to eq nil + expect(controller.__send__(:order_to_update)).to eq nil end end @@ -422,7 +422,7 @@ RSpec.describe Spree::OrdersController, type: :controller do context "and the order is not editable" do it "returns nil" do - expect(controller.send(:order_to_update)).to eq nil + expect(controller.__send__(:order_to_update)).to eq nil end end @@ -441,7 +441,7 @@ RSpec.describe Spree::OrdersController, type: :controller do end it "returns the order" do - expect(controller.send(:order_to_update)).to eq order + expect(controller.__send__(:order_to_update)).to eq order end end end diff --git a/spec/helpers/order_cycles_helper_spec.rb b/spec/helpers/order_cycles_helper_spec.rb index cb7a7d1151..aaf39267bc 100644 --- a/spec/helpers/order_cycles_helper_spec.rb +++ b/spec/helpers/order_cycles_helper_spec.rb @@ -44,25 +44,29 @@ RSpec.describe OrderCyclesHelper, type: :helper do it "returns enterprises without shipping methods as disabled" do create(:payment_method, distributors: [e]) - expect(helper.send(:validated_enterprise_options, [e], shipping_and_payment_methods: true)) + expect(helper.__send__(:validated_enterprise_options, [e], + shipping_and_payment_methods: true)) .to eq [['enterprise (no shipping methods)', e.id, { disabled: true }]] end it "returns enterprises without payment methods as disabled" do create(:shipping_method, distributors: [e]) - expect(helper.send(:validated_enterprise_options, [e], shipping_and_payment_methods: true)) + expect(helper.__send__(:validated_enterprise_options, [e], + shipping_and_payment_methods: true)) .to eq [['enterprise (no payment methods)', e.id, { disabled: true }]] end it "returns enterprises with unavailable payment methods as disabled" do create(:shipping_method, distributors: [e]) create(:payment_method, distributors: [e], active: false) - expect(helper.send(:validated_enterprise_options, [e], shipping_and_payment_methods: true)) + expect(helper.__send__(:validated_enterprise_options, [e], + shipping_and_payment_methods: true)) .to eq [['enterprise (no payment methods)', e.id, { disabled: true }]] end it "returns enterprises with neither shipping nor payment methods as disabled" do - expect(helper.send(:validated_enterprise_options, [e], shipping_and_payment_methods: true)) + expect(helper.__send__(:validated_enterprise_options, [e], + shipping_and_payment_methods: true)) .to eq [['enterprise (no shipping or payment methods)', e.id, { disabled: true }]] end end diff --git a/spec/jobs/subscription_confirm_job_spec.rb b/spec/jobs/subscription_confirm_job_spec.rb index bdad78a5a9..6faae26b68 100644 --- a/spec/jobs/subscription_confirm_job_spec.rb +++ b/spec/jobs/subscription_confirm_job_spec.rb @@ -22,7 +22,7 @@ RSpec.describe SubscriptionConfirmJob do placed_at: 5.minutes.ago) end let!(:order) { proxy_order.initialise_order! } - let(:proxy_orders) { job.send(:unconfirmed_proxy_orders) } + let(:proxy_orders) { job.__send__(:unconfirmed_proxy_orders) } before do Orders::WorkflowService.new(order).complete! @@ -124,7 +124,7 @@ RSpec.describe SubscriptionConfirmJob do it "returns closed order cycles whose orders_close_at " \ "or updated_at date is within the last hour" do - order_cycles = job.send(:recently_closed_order_cycles) + order_cycles = job.__send__(:recently_closed_order_cycles) expect(order_cycles).to include order_cycle3, order_cycle4 expect(order_cycles).not_to include order_cycle1, order_cycle2, order_cycle5 end @@ -176,14 +176,14 @@ RSpec.describe SubscriptionConfirmJob do end it "runs the charges in offline mode" do - job.send(:confirm_order!, order) + job.__send__(:confirm_order!, order) expect(stripe_sca_payment_method.provider).to have_received(:purchase) end it "uses #capture if the payment is already authorized" do allow(stripe_sca_payment).to receive(:preauthorized?) { true } expect(stripe_sca_payment_method.provider).to receive(:capture) - job.send(:confirm_order!, order) + job.__send__(:confirm_order!, order) end it "authorizes the payment with Stripe" do @@ -192,7 +192,7 @@ RSpec.describe SubscriptionConfirmJob do expect(OrderManagement::Order::StripeScaPaymentAuthorize). to receive_message_chain(:new, :call!) { true } - job.send(:confirm_order!, order) + job.__send__(:confirm_order!, order) end end end @@ -216,7 +216,7 @@ RSpec.describe SubscriptionConfirmJob do it "sends a failed payment email" do expect(job).to receive(:send_failed_payment_email) expect(job).not_to receive(:send_confirmation_email) - job.send(:confirm_order!, order) + job.__send__(:confirm_order!, order) end end @@ -233,7 +233,7 @@ RSpec.describe SubscriptionConfirmJob do expect(job).to receive(:send_failed_payment_email) expect(job).not_to receive(:send_confirmation_email) expect(job).not_to receive(:send_payment_authorization_emails) - job.send(:confirm_order!, order) + job.__send__(:confirm_order!, order) end end @@ -247,7 +247,7 @@ RSpec.describe SubscriptionConfirmJob do end it "sends only a subscription confirm email, no regular confirmation emails" do - expect{ job.send(:confirm_order!, order) } + expect{ job.__send__(:confirm_order!, order) } .not_to have_enqueued_mail(Spree::OrderMailer, :confirm_email_for_customer) expect(job).to have_received(:send_confirmation_email).once @@ -268,7 +268,7 @@ RSpec.describe SubscriptionConfirmJob do it "records a success and sends the email" do expect(order).to receive(:update_order!) expect(job).to receive(:record_success).with(order).once - job.send(:send_confirmation_email, order) + job.__send__(:send_confirmation_email, order) expect(SubscriptionMailer).to have_received(:confirmation_email).with(order) expect(mail_mock).to have_received(:deliver_now) end @@ -285,7 +285,7 @@ RSpec.describe SubscriptionConfirmJob do it "records and logs an error and sends the email" do expect(order).to receive(:update_order!) expect(job).to receive(:record_and_log_error).with(:failed_payment, order, nil).once - job.send(:send_failed_payment_email, order) + job.__send__(:send_failed_payment_email, order) expect(SubscriptionMailer).to have_received(:failed_payment_email).with(order) expect(mail_mock).to have_received(:deliver_now) end diff --git a/spec/jobs/subscription_placement_job_spec.rb b/spec/jobs/subscription_placement_job_spec.rb index 26c7093c31..e2828f18b5 100644 --- a/spec/jobs/subscription_placement_job_spec.rb +++ b/spec/jobs/subscription_placement_job_spec.rb @@ -25,29 +25,29 @@ RSpec.describe SubscriptionPlacementJob do } # OK it "ignores proxy orders where the OC has closed" do - expect(job.send(:proxy_orders)).to include proxy_order + expect(job.__send__(:proxy_orders)).to include proxy_order proxy_order.update!(order_cycle_id: order_cycle2.id) - expect(job.send(:proxy_orders)).not_to include proxy_order + expect(job.__send__(:proxy_orders)).not_to include proxy_order end it "ignores proxy orders for paused or cancelled subscriptions" do - expect(job.send(:proxy_orders)).to include proxy_order + expect(job.__send__(:proxy_orders)).to include proxy_order subscription.update!(paused_at: 1.minute.ago) - expect(job.send(:proxy_orders)).not_to include proxy_order + expect(job.__send__(:proxy_orders)).not_to include proxy_order subscription.update!(paused_at: nil) - expect(job.send(:proxy_orders)).to include proxy_order + expect(job.__send__(:proxy_orders)).to include proxy_order subscription.update!(canceled_at: 1.minute.ago) - expect(job.send(:proxy_orders)).not_to include proxy_order + expect(job.__send__(:proxy_orders)).not_to include proxy_order end it "ignores proxy orders that have been marked as cancelled or placed" do - expect(job.send(:proxy_orders)).to include proxy_order + expect(job.__send__(:proxy_orders)).to include proxy_order proxy_order.update!(canceled_at: 5.minutes.ago) - expect(job.send(:proxy_orders)).not_to include proxy_order + expect(job.__send__(:proxy_orders)).not_to include proxy_order proxy_order.update!(canceled_at: nil) - expect(job.send(:proxy_orders)).to include proxy_order + expect(job.__send__(:proxy_orders)).to include proxy_order proxy_order.update!(placed_at: 5.minutes.ago) - expect(job.send(:proxy_orders)).not_to include proxy_order + expect(job.__send__(:proxy_orders)).not_to include proxy_order end end diff --git a/spec/lib/open_food_network/address_finder_spec.rb b/spec/lib/open_food_network/address_finder_spec.rb index 499f7dff86..c7068eefe9 100644 --- a/spec/lib/open_food_network/address_finder_spec.rb +++ b/spec/lib/open_food_network/address_finder_spec.rb @@ -51,7 +51,7 @@ module OpenFoodNetwork before { allow(finder).to receive(:last_used_bill_address) { address } } it "returns a clone of the bill_address" do - expect(finder.send(:fallback_bill_address)).to eq "address_clone" + expect(finder.__send__(:fallback_bill_address)).to eq "address_clone" end end @@ -59,7 +59,7 @@ module OpenFoodNetwork before { allow(finder).to receive(:last_used_bill_address) { nil } } it "returns a new empty address" do - expect(finder.send(:fallback_bill_address)).to eq Spree::Address.default + expect(finder.__send__(:fallback_bill_address)).to eq Spree::Address.default end end end @@ -72,7 +72,7 @@ module OpenFoodNetwork before { allow(finder).to receive(:last_used_ship_address) { address } } it "returns a clone of the ship_address" do - expect(finder.send(:fallback_ship_address)).to eq "address_clone" + expect(finder.__send__(:fallback_ship_address)).to eq "address_clone" end end @@ -80,7 +80,7 @@ module OpenFoodNetwork before { allow(finder).to receive(:last_used_ship_address) { nil } } it "returns a new empty address" do - expect(finder.send(:fallback_ship_address)).to eq Spree::Address.default + expect(finder.__send__(:fallback_ship_address)).to eq Spree::Address.default end end end @@ -105,7 +105,7 @@ module OpenFoodNetwork end it "returns nil" do - expect(finder.send(:last_used_bill_address)).to eq nil + expect(finder.__send__(:last_used_bill_address)).to eq nil end end end @@ -119,7 +119,7 @@ module OpenFoodNetwork before { order.update_attribute(:bill_address, address) } it "returns the bill_address" do - expect(finder.send(:last_used_bill_address)).to eq address + expect(finder.__send__(:last_used_bill_address)).to eq address end end @@ -127,13 +127,13 @@ module OpenFoodNetwork before { order } it "return nil" do - expect(finder.send(:last_used_bill_address)).to eq nil + expect(finder.__send__(:last_used_bill_address)).to eq nil end end context "when no orders exist" do it "returns nil" do - expect(finder.send(:last_used_bill_address)).to eq nil + expect(finder.__send__(:last_used_bill_address)).to eq nil end end end @@ -160,7 +160,7 @@ module OpenFoodNetwork end it "returns nil" do - expect(finder.send(:last_used_ship_address)).to eq nil + expect(finder.__send__(:last_used_ship_address)).to eq nil end end end @@ -180,7 +180,7 @@ module OpenFoodNetwork before { order.shipping_method.update_attribute(:require_ship_address, true) } it "returns the ship_address" do - expect(finder.send(:last_used_ship_address)).to eq address + expect(finder.__send__(:last_used_ship_address)).to eq address end end @@ -188,7 +188,7 @@ module OpenFoodNetwork before { order.shipping_method.update_attribute(:require_ship_address, false) } it "returns nil" do - expect(finder.send(:last_used_ship_address)).to eq nil + expect(finder.__send__(:last_used_ship_address)).to eq nil end end end @@ -200,13 +200,13 @@ module OpenFoodNetwork } it "return nil" do - expect(finder.send(:last_used_ship_address)).to eq nil + expect(finder.__send__(:last_used_ship_address)).to eq nil end end context "when no orders exist" do it "returns nil" do - expect(finder.send(:last_used_ship_address)).to eq nil + expect(finder.__send__(:last_used_ship_address)).to eq nil end end end @@ -224,14 +224,14 @@ module OpenFoodNetwork context "when the customer email matches the raw email" do before{ allow(customer).to receive(:email) { "email@email.com" } } it "returns true" do - expect(finder.send(:allow_search_by_email?)).to be true + expect(finder.__send__(:allow_search_by_email?)).to be true end end context "when the customer email does not match the raw email" do before{ allow(customer).to receive(:email) { "nah@email.com" } } it "returns false" do - expect(finder.send(:allow_search_by_email?)).to be false + expect(finder.__send__(:allow_search_by_email?)).to be false end end end @@ -243,28 +243,28 @@ module OpenFoodNetwork context "when the user email matches the raw email" do before{ allow(user).to receive(:email) { "email@email.com" } } it "returns true" do - expect(finder.send(:allow_search_by_email?)).to be true + expect(finder.__send__(:allow_search_by_email?)).to be true end end context "when the user email does not match the raw email" do before{ allow(user).to receive(:email) { "nah@email.com" } } it "returns false" do - expect(finder.send(:allow_search_by_email?)).to be false + expect(finder.__send__(:allow_search_by_email?)).to be false end end end context "when neither a customer nor a user has been provided" do it "returns false" do - expect(finder.send(:allow_search_by_email?)).to be false + expect(finder.__send__(:allow_search_by_email?)).to be false end end end context "when an email address is not provided" do it "returns false" do - expect(finder.send(:allow_search_by_email?)).to be false + expect(finder.__send__(:allow_search_by_email?)).to be false end end end diff --git a/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb b/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb index 98f7db2325..b16b11f124 100644 --- a/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_applicator_spec.rb @@ -70,7 +70,7 @@ module OpenFoodNetwork describe "#line_item_adjustment_label" do it "makes an adjustment label for a line item" do - expect(applicator.send(:line_item_adjustment_label)). + expect(applicator.__send__(:line_item_adjustment_label)). to eq("Bananas - packing name fee by distributor Ballantyne") end end @@ -79,7 +79,7 @@ module OpenFoodNetwork let(:applicator) { EnterpriseFeeApplicator.new enterprise_fee, nil, 'distributor' } it "makes an adjustment label for an order" do - expect(applicator.send(:order_adjustment_label)). + expect(applicator.__send__(:order_adjustment_label)). to eq("Whole order - packing name fee by distributor Ballantyne") end end diff --git a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb index 5478e99934..58da6263ed 100644 --- a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb @@ -235,11 +235,13 @@ module OpenFoodNetwork describe "fetching enterprise fees with pre-loaded exchange details" do it "scopes enterprise fees to those on exchanges for the current order cycle" do - expect(subject.send(:per_item_enterprise_fees_with_exchange_details)).to eq([ef_exchange]) + expect(subject.__send__(:per_item_enterprise_fees_with_exchange_details)).to eq( + [ef_exchange] + ) end it "includes the exchange variant id" do - expect(subject.send(:per_item_enterprise_fees_with_exchange_details) + expect(subject.__send__(:per_item_enterprise_fees_with_exchange_details) .first.variant_id.to_i).to eq(v.id) end @@ -248,22 +250,24 @@ module OpenFoodNetwork receiver: distributor_other, enterprise_fees: [ef_other_distributor], variants: [v]) - expect(subject.send(:per_item_enterprise_fees_with_exchange_details)).to eq([ef_exchange]) + expect(subject.__send__(:per_item_enterprise_fees_with_exchange_details)).to eq( + [ef_exchange] + ) end end describe "loading exchange fees" do - let(:exchange_fees) { subject.send(:per_item_enterprise_fees_with_exchange_details) } + let(:exchange_fees) { subject.__send__(:per_item_enterprise_fees_with_exchange_details) } it "loads exchange fees" do - subject.send(:load_exchange_fees, exchange_fees) + subject.__send__(:load_exchange_fees, exchange_fees) expect(indexed_enterprise_fees).to eq(v.id => [ef_exchange]) end end describe "loading coordinator fees" do it "loads coordinator fees" do - subject.send(:load_coordinator_fees) + subject.__send__(:load_coordinator_fees) expect(indexed_enterprise_fees).to eq(v.id => [ef_coordinator]) end end @@ -307,7 +311,7 @@ module OpenFoodNetwork end it "makes fee applicators for a line item" do - expect(efc.send(:per_item_enterprise_fee_applicators_for, line_item.variant)) + expect(efc.__send__(:per_item_enterprise_fee_applicators_for, line_item.variant)) .to eq [OpenFoodNetwork::EnterpriseFeeApplicator.new(ef1, line_item.variant, 'supplier'), OpenFoodNetwork::EnterpriseFeeApplicator.new(ef2, line_item.variant, @@ -322,7 +326,8 @@ module OpenFoodNetwork let(:order) { double(:order, distributor: nil, order_cycle: nil) } it "does not make applicators for an order" do - expect(efc.send(:per_item_enterprise_fee_applicators_for, line_item.variant)).to eq [] + expect(efc.__send__(:per_item_enterprise_fee_applicators_for, + line_item.variant)).to eq [] end end end @@ -352,7 +357,7 @@ module OpenFoodNetwork end it "makes fee applicators for an order" do - expect(efc.send(:per_order_enterprise_fee_applicators_for, order)) + expect(efc.__send__(:per_order_enterprise_fee_applicators_for, order)) .to eq [OpenFoodNetwork::EnterpriseFeeApplicator.new(ef1, nil, 'supplier'), OpenFoodNetwork::EnterpriseFeeApplicator.new(ef2, nil, 'distributor'), OpenFoodNetwork::EnterpriseFeeApplicator.new(ef3, nil, 'coordinator')] @@ -364,7 +369,7 @@ module OpenFoodNetwork let(:order) { double(:order, distributor: nil, order_cycle: nil) } it "does not make applicators for an order" do - expect(efc.send(:per_order_enterprise_fee_applicators_for, order)).to eq [] + expect(efc.__send__(:per_order_enterprise_fee_applicators_for, order)).to eq [] end end end diff --git a/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb b/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb index e12cd9c6a9..2eb416eba4 100644 --- a/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb +++ b/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb @@ -151,7 +151,7 @@ module OpenFoodNetwork expect(applicator).to receive(:destroy_untouched_exchanges) applicator.go! - expect(applicator.send(:untouched_exchanges)).to eq([exchange]) + expect(applicator.__send__(:untouched_exchanges)).to eq([exchange]) end it "compares exchanges by id only" do @@ -164,7 +164,7 @@ module OpenFoodNetwork @touched_exchanges = [e2] end - expect(applicator.send(:untouched_exchanges)).to eq([]) + expect(applicator.__send__(:untouched_exchanges)).to eq([]) end context "as a manager of the coordinator" do @@ -176,7 +176,7 @@ module OpenFoodNetwork expect(applicator).to receive(:untouched_exchanges) { exchanges } exchanges.each { |ex| expect(ex).to receive(:destroy) } - applicator.send(:destroy_untouched_exchanges) + applicator.__send__(:destroy_untouched_exchanges) end end @@ -186,7 +186,7 @@ module OpenFoodNetwork it "does not destroy any exchanges" do expect(applicator).not_to receive(:with_permission) - applicator.send(:destroy_untouched_exchanges) + applicator.__send__(:destroy_untouched_exchanges) end end end @@ -210,18 +210,18 @@ module OpenFoodNetwork let!(:coordinator) { oc.coordinator } let!(:applicator) { OrderCycleFormApplicator.new(oc, user) } let(:ids) do - applicator.send(:outgoing_exchange_variant_ids, - enterprise_id: enterprise.id, - variants: { - v1.id.to_s => true, - v2.id.to_s => true, - v3.id.to_s => true, - v5.id.to_s => false, - v6.id.to_s => false, - v7.id.to_s => true, - v8.id.to_s => true, - v9.id.to_s => true - }) + applicator.__send__(:outgoing_exchange_variant_ids, + enterprise_id: enterprise.id, + variants: { + v1.id.to_s => true, + v2.id.to_s => true, + v3.id.to_s => true, + v5.id.to_s => false, + v6.id.to_s => false, + v7.id.to_s => true, + v8.id.to_s => true, + v9.id.to_s => true + }) end before do @@ -277,16 +277,16 @@ module OpenFoodNetwork let!(:coordinator) { oc.coordinator } let!(:applicator) { OrderCycleFormApplicator.new(oc, user) } let(:ids) do - applicator.send(:incoming_exchange_variant_ids, - enterprise_id: enterprise.id, - variants: { - v1.id.to_s => true, - v2.id.to_s => true, - v3.id.to_s => true, - v4.id.to_s => false, - v5.id.to_s => false, - v6.id.to_s => false - }) + applicator.__send__(:incoming_exchange_variant_ids, + enterprise_id: enterprise.id, + variants: { + v1.id.to_s => true, + v2.id.to_s => true, + v3.id.to_s => true, + v4.id.to_s => false, + v5.id.to_s => false, + v6.id.to_s => false + }) end before do @@ -328,7 +328,7 @@ module OpenFoodNetwork applicator = OrderCycleFormApplicator.new(nil, user) allow(applicator).to receive(:permitted_enterprises) { [e] } - expect(applicator.send(:permission_for, ex)).to be true + expect(applicator.__send__(:permission_for, ex)).to be true end it "returns false otherwise" do @@ -338,7 +338,7 @@ module OpenFoodNetwork applicator = OrderCycleFormApplicator.new(nil, user) allow(applicator).to receive(:permitted_enterprises) { [] } - expect(applicator.send(:permission_for, ex)).to be false + expect(applicator.__send__(:permission_for, ex)).to be false end end end @@ -354,17 +354,18 @@ module OpenFoodNetwork exchange = FactoryBot.create(:exchange, order_cycle: oc) applicator = OrderCycleFormApplicator.new(oc, user) - expect(applicator.send(:exchange_exists?, exchange.sender_id, exchange.receiver_id, - exchange.incoming)).to be true - expect(applicator.send(:exchange_exists?, exchange.sender_id, exchange.receiver_id, - !exchange.incoming)).to be false - expect(applicator.send(:exchange_exists?, exchange.receiver_id, exchange.sender_id, - exchange.incoming)).to be false - expect(applicator.send(:exchange_exists?, exchange.sender_id, 999_999, - exchange.incoming)).to be false - expect(applicator.send(:exchange_exists?, 999_999, exchange.receiver_id, - exchange.incoming)).to be false - expect(applicator.send(:exchange_exists?, 999_999, 888_888, exchange.incoming)).to be false + expect(applicator.__send__(:exchange_exists?, exchange.sender_id, exchange.receiver_id, + exchange.incoming)).to be true + expect(applicator.__send__(:exchange_exists?, exchange.sender_id, exchange.receiver_id, + !exchange.incoming)).to be false + expect(applicator.__send__(:exchange_exists?, exchange.receiver_id, exchange.sender_id, + exchange.incoming)).to be false + expect(applicator.__send__(:exchange_exists?, exchange.sender_id, 999_999, + exchange.incoming)).to be false + expect(applicator.__send__(:exchange_exists?, 999_999, exchange.receiver_id, + exchange.incoming)).to be false + expect(applicator.__send__(:exchange_exists?, 999_999, 888_888, + exchange.incoming)).to be false end describe "adding exchanges" do @@ -381,10 +382,10 @@ module OpenFoodNetwork context "as a manager of the coorindator" do before do allow(applicator).to receive(:manages_coordinator?) { true } - applicator.send(:touched_exchanges=, []) - applicator.send(:add_exchange, sender.id, receiver.id, incoming, - variant_ids: [variant1.id, variant2.id], - enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id]) + applicator.__send__(:touched_exchanges=, []) + applicator.__send__(:add_exchange, sender.id, receiver.id, incoming, + variant_ids: [variant1.id, variant2.id], + enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id]) end it "adds new exchanges" do @@ -395,16 +396,16 @@ module OpenFoodNetwork expect(exchange.variants).to match_array [variant1, variant2] expect(exchange.enterprise_fees).to match_array [enterprise_fee1, enterprise_fee2] - expect(applicator.send(:touched_exchanges)).to eq([exchange]) + expect(applicator.__send__(:touched_exchanges)).to eq([exchange]) end end context "as a user which does not manage the coorindator" do before do allow(applicator).to receive(:manages_coordinator?) { false } - applicator.send(:add_exchange, sender.id, receiver.id, incoming, - variant_ids: [variant1.id, variant2.id], - enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id]) + applicator.__send__(:add_exchange, sender.id, receiver.id, incoming, + variant_ids: [variant1.id, variant2.id], + enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id]) end it "does not add new exchanges" do @@ -437,13 +438,13 @@ module OpenFoodNetwork allow(applicator).to receive(:manages_coordinator?) { true } allow(applicator).to receive(:manager_for) { false } allow(applicator).to receive(:permission_for) { true } - applicator.send(:touched_exchanges=, []) - applicator.send(:update_exchange, sender.id, receiver.id, incoming, - variant_ids: [variant1.id, variant3.id], - enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], - pickup_time: 'New Pickup Time', - pickup_instructions: 'New Pickup Instructions', - tag_list: 'wholesale') + applicator.__send__(:touched_exchanges=, []) + applicator.__send__(:update_exchange, sender.id, receiver.id, incoming, + variant_ids: [variant1.id, variant3.id], + enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], + pickup_time: 'New Pickup Time', + pickup_instructions: 'New Pickup Instructions', + tag_list: 'wholesale') end it "updates the variants, enterprise fees tags, and pickup information of the exchange" do @@ -453,7 +454,7 @@ module OpenFoodNetwork expect(exchange.pickup_time).to eq 'New Pickup Time' expect(exchange.pickup_instructions).to eq 'New Pickup Instructions' expect(exchange.tag_list).to eq ['wholesale'] - expect(applicator.send(:touched_exchanges)).to eq [exchange] + expect(applicator.__send__(:touched_exchanges)).to eq [exchange] end end @@ -462,13 +463,13 @@ module OpenFoodNetwork allow(applicator).to receive(:manages_coordinator?) { false } allow(applicator).to receive(:manager_for) { true } allow(applicator).to receive(:permission_for) { true } - applicator.send(:touched_exchanges=, []) - applicator.send(:update_exchange, sender.id, receiver.id, incoming, - variant_ids: [variant1.id, variant3.id], - enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], - pickup_time: 'New Pickup Time', - pickup_instructions: 'New Pickup Instructions', - tag_list: 'wholesale') + applicator.__send__(:touched_exchanges=, []) + applicator.__send__(:update_exchange, sender.id, receiver.id, incoming, + variant_ids: [variant1.id, variant3.id], + enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], + pickup_time: 'New Pickup Time', + pickup_instructions: 'New Pickup Instructions', + tag_list: 'wholesale') end it "updates the variants, enterprise fees, tags and pickup information of the exchange" do @@ -478,7 +479,7 @@ module OpenFoodNetwork expect(exchange.pickup_time).to eq 'New Pickup Time' expect(exchange.pickup_instructions).to eq 'New Pickup Instructions' expect(exchange.tag_list).to eq ['wholesale'] - expect(applicator.send(:touched_exchanges)).to eq [exchange] + expect(applicator.__send__(:touched_exchanges)).to eq [exchange] end end @@ -487,13 +488,13 @@ module OpenFoodNetwork allow(applicator).to receive(:manages_coordinator?) { false } allow(applicator).to receive(:manager_for) { false } allow(applicator).to receive(:permission_for) { true } - applicator.send(:touched_exchanges=, []) - applicator.send(:update_exchange, sender.id, receiver.id, incoming, - variant_ids: [variant1.id, variant3.id], - enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], - pickup_time: 'New Pickup Time', - pickup_instructions: 'New Pickup Instructions', - tag_list: 'wholesale') + applicator.__send__(:touched_exchanges=, []) + applicator.__send__(:update_exchange, sender.id, receiver.id, incoming, + variant_ids: [variant1.id, variant3.id], + enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], + pickup_time: 'New Pickup Time', + pickup_instructions: 'New Pickup Instructions', + tag_list: 'wholesale') end it "updates the variants in the exchange, but not the fees, tags or pickup information" do @@ -503,7 +504,7 @@ module OpenFoodNetwork expect(exchange.pickup_time).not_to eq 'New Pickup Time' expect(exchange.pickup_instructions).not_to eq 'New Pickup Instructions' expect(exchange.tag_list).to eq [] - expect(applicator.send(:touched_exchanges)).to eq [exchange] + expect(applicator.__send__(:touched_exchanges)).to eq [exchange] end end end @@ -516,8 +517,8 @@ module OpenFoodNetwork incoming = true expect do - applicator.send(:touched_exchanges=, []) - applicator.send(:add_exchange, sender.id, receiver.id, incoming) + applicator.__send__(:touched_exchanges=, []) + applicator.__send__(:add_exchange, sender.id, receiver.id, incoming) end.to change { Exchange.count }.by(0) end @@ -531,9 +532,9 @@ module OpenFoodNetwork receiver:, incoming:) variant1 = FactoryBot.create(:variant) - applicator.send(:touched_exchanges=, []) - applicator.send(:update_exchange, sender.id, receiver.id, incoming, - variant_ids: [variant1.id]) + applicator.__send__(:touched_exchanges=, []) + applicator.__send__(:update_exchange, sender.id, receiver.id, incoming, + variant_ids: [variant1.id]) expect(exchange.variants).not_to eq([variant1]) end diff --git a/spec/lib/open_food_network/permissions_spec.rb b/spec/lib/open_food_network/permissions_spec.rb index d0c678a874..8d48d89121 100644 --- a/spec/lib/open_food_network/permissions_spec.rb +++ b/spec/lib/open_food_network/permissions_spec.rb @@ -16,8 +16,8 @@ module OpenFoodNetwork before { allow(user).to receive(:admin?) { true } } it "returns all enterprises" do - expect(permissions.send(:managed_and_related_enterprises_granting, - :some_permission)).to match_array [e1, e2] + expect(permissions.__send__(:managed_and_related_enterprises_granting, + :some_permission)).to match_array [e1, e2] end end @@ -30,8 +30,8 @@ module OpenFoodNetwork expect(permissions).to receive(:related_enterprises_granting).with(:some_permission) { Enterprise.where(id: e3).select(:id) } - expect(permissions.send(:managed_and_related_enterprises_granting, - :some_permission)).to match_array [e1, e3] + expect(permissions.__send__(:managed_and_related_enterprises_granting, + :some_permission)).to match_array [e1, e3] end end end @@ -41,8 +41,8 @@ module OpenFoodNetwork before { allow(user).to receive(:admin?) { true } } it "returns all enterprises" do - expect(permissions.send(:managed_and_related_enterprises_granting, - :some_permission)).to match_array [e1, e2] + expect(permissions.__send__(:managed_and_related_enterprises_granting, + :some_permission)).to match_array [e1, e2] end end @@ -59,8 +59,8 @@ module OpenFoodNetwork expect(permissions).to receive(:related_enterprises_granted).with(:some_permission) { Enterprise.where(id: e4).select(:id) } - expect(permissions.send(:managed_and_related_enterprises_with, - :some_permission)).to match_array [e1, e3, e4] + expect(permissions.__send__(:managed_and_related_enterprises_with, + :some_permission)).to match_array [e1, e3, e4] end end end @@ -296,12 +296,12 @@ module OpenFoodNetwork it "returns the enterprises" do allow(permissions).to receive(:managed_enterprises) { Enterprise.where(id: e2) } - expect(permissions.send(:related_enterprises_granting, permission)).to eq([e1]) + expect(permissions.__send__(:related_enterprises_granting, permission)).to eq([e1]) end it "returns an empty array when there are none" do allow(permissions).to receive(:managed_enterprises) { Enterprise.where(id: e1) } - expect(permissions.send(:related_enterprises_granting, permission)).to eq([]) + expect(permissions.__send__(:related_enterprises_granting, permission)).to eq([]) end end @@ -316,13 +316,15 @@ module OpenFoodNetwork it "returns managed enterprises" do expect(permissions).to receive(:managed_enterprises) { Enterprise.where(id: e1) } - expect(permissions.send(:managed_and_related_enterprises_granting, permission)).to eq([e1]) + expect(permissions.__send__(:managed_and_related_enterprises_granting, + permission)).to eq([e1]) end it "returns permitted enterprises" do expect(permissions).to receive(:related_enterprises_granting).with(permission). and_return(Enterprise.where(id: e2).select(:id)) - expect(permissions.send(:managed_and_related_enterprises_granting, permission)).to eq([e2]) + expect(permissions.__send__(:managed_and_related_enterprises_granting, + permission)).to eq([e2]) end end diff --git a/spec/lib/open_food_network/tag_rule_applicator_spec.rb b/spec/lib/open_food_network/tag_rule_applicator_spec.rb index bc4195deea..6ee30791cf 100644 --- a/spec/lib/open_food_network/tag_rule_applicator_spec.rb +++ b/spec/lib/open_food_network/tag_rule_applicator_spec.rb @@ -76,7 +76,7 @@ module OpenFoodNetwork it "does not match rules without customer tags" do rule = double(:rule, preferred_customer_tags: "") - expect(applicator.send(:customer_tags_match?, rule)).to be false + expect(applicator.__send__(:customer_tags_match?, rule)).to be false end end @@ -89,16 +89,16 @@ module OpenFoodNetwork it "does not match rules without customer tags" do rule = double(:rule, preferred_customer_tags: "") - expect(applicator.send(:customer_tags_match?, rule)).to be false + expect(applicator.__send__(:customer_tags_match?, rule)).to be false end end context "when customer_tags are present" do let!(:customer_tags) { ["tag1"] } - let(:rules) { applicator.send(:rules) } - let(:customer_rules) { applicator.send(:customer_rules) } - let(:default_rules) { applicator.send(:default_rules) } + let(:rules) { applicator.__send__(:rules) } + let(:customer_rules) { applicator.__send__(:customer_rules) } + let(:default_rules) { applicator.__send__(:default_rules) } it "stores enterprise, rule_class and customer_tags as instance variables" do expect(applicator.enterprise).to eq enterprise @@ -230,7 +230,7 @@ module OpenFoodNetwork before{ allow(customer_rule).to receive(:tags_match?).with(dummy) { true } } it "returns the value of customer_rule.reject_matched?" do - expect(applicator.send(:reject?, dummy)).to eq "customer_rule.reject_matched?" + expect(applicator.__send__(:reject?, dummy)).to eq "customer_rule.reject_matched?" end end @@ -241,7 +241,7 @@ module OpenFoodNetwork before{ allow(default_rule).to receive(:tags_match?) { true } } it "returns the value of the default_rule.reject_matched?" do - expect(applicator.send(:reject?, dummy)).to eq "default_rule.reject_matched?" + expect(applicator.__send__(:reject?, dummy)).to eq "default_rule.reject_matched?" end end @@ -249,7 +249,7 @@ module OpenFoodNetwork before{ allow(default_rule).to receive(:tags_match?) { false } } it "returns false" do - expect(applicator.send(:reject?, dummy)).to be false + expect(applicator.__send__(:reject?, dummy)).to be false end end end diff --git a/spec/lib/reports/xero_invoices_report_spec.rb b/spec/lib/reports/xero_invoices_report_spec.rb index 7f64e4b5c1..cc98f5c60e 100644 --- a/spec/lib/reports/xero_invoices_report_spec.rb +++ b/spec/lib/reports/xero_invoices_report_spec.rb @@ -84,7 +84,7 @@ module Reporting describe "when no initial invoice number is given" do it "returns the order number" do - expect(subject.send(:invoice_number_for, order, 123)).to eq('R731032860') + expect(subject.__send__(:invoice_number_for, order, 123)).to eq('R731032860') end end @@ -92,7 +92,7 @@ module Reporting subject { Base.new(user, { initial_invoice_number: '123' }) } it "increments the number by the index" do - expect(subject.send(:invoice_number_for, order, 456)).to eq(579) + expect(subject.__send__(:invoice_number_for, order, 456)).to eq(579) end end end diff --git a/spec/lib/stripe/webhook_handler_spec.rb b/spec/lib/stripe/webhook_handler_spec.rb index 6750123fb4..8218f7fa61 100644 --- a/spec/lib/stripe/webhook_handler_spec.rb +++ b/spec/lib/stripe/webhook_handler_spec.rb @@ -9,7 +9,7 @@ module Stripe let(:handler) { WebhookHandler.new(event) } describe "event_mappings" do - it { expect(handler.send(:event_mappings)).to be_a Hash } + it { expect(handler.__send__(:event_mappings)).to be_a Hash } end describe "known_event?" do @@ -18,7 +18,7 @@ module Stripe allow(handler).to receive(:event_mappings) { { 'some.event' => :something } } end - it { expect(handler.send(:known_event?)).to be true } + it { expect(handler.__send__(:known_event?)).to be true } end context "when event mappings do not know about the event type" do @@ -26,7 +26,7 @@ module Stripe allow(handler).to receive(:event_mappings) { { 'some.other.event' => :something } } end - it { expect(handler.send(:known_event?)).to be false } + it { expect(handler.__send__(:known_event?)).to be false } end end @@ -58,7 +58,7 @@ module Stripe context "when the event has no 'account' attribute" do it "does destroy stripe accounts, returns :ignored" do expect(handler).not_to receive(:destroy_stripe_accounts_linked_to) - expect(handler.send(:deauthorize)).to be :ignored + expect(handler.__send__(:deauthorize)).to be :ignored end end @@ -74,7 +74,7 @@ module Stripe } end - it { expect(handler.send(:deauthorize)).to be :success } + it { expect(handler.__send__(:deauthorize)).to be :success } end context "when no stripe accounts are destroyed" do @@ -84,7 +84,7 @@ module Stripe } end - it { expect(handler.send(:deauthorize)).to be :ignored } + it { expect(handler.__send__(:deauthorize)).to be :ignored } end end end diff --git a/spec/models/calculator/weight_spec.rb b/spec/models/calculator/weight_spec.rb index ec7907f638..0ab084057b 100644 --- a/spec/models/calculator/weight_spec.rb +++ b/spec/models/calculator/weight_spec.rb @@ -75,7 +75,7 @@ RSpec.describe Calculator::Weight do let(:calculator) { described_class.new(preferred_per_unit: 6, preferred_unit_from_list: "kg") } let(:line_item) do build_stubbed(:line_item, variant:, quantity: 2).tap do |object| - object.send(:calculate_final_weight_volume) + object.__send__(:calculate_final_weight_volume) end end diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index f69c6f96d2..6e26d0415f 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -857,7 +857,7 @@ RSpec.describe Enterprise do allow(Enterprise).to receive(:find_available_permalink).and_return("available_permalink") expect(Enterprise).to receive(:find_available_permalink).with("Name To Turn Into A Permalink") expect do - enterprise.send(:initialize_permalink) + enterprise.__send__(:initialize_permalink) end.to change { enterprise.permalink }.to("available_permalink") end diff --git a/spec/models/exchange_spec.rb b/spec/models/exchange_spec.rb index b2a9c92f35..907f58fe0a 100644 --- a/spec/models/exchange_spec.rb +++ b/spec/models/exchange_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Exchange do [:order_cycle, :sender, :receiver].each do |attr| it "should not be valid without #{attr}" do e = build(:exchange) - e.send("#{attr}=", nil) + e.__send__("#{attr}=", nil) expect(e).not_to be_valid end end diff --git a/spec/models/spree/order_inventory_spec.rb b/spec/models/spree/order_inventory_spec.rb index 0aa07585f5..814cca78d6 100644 --- a/spec/models/spree/order_inventory_spec.rb +++ b/spec/models/spree/order_inventory_spec.rb @@ -37,14 +37,14 @@ RSpec.describe Spree::OrderInventory do it "doesn't unstock items" do expect(shipment.stock_location).not_to receive(:unstock) - expect(subject.send(:add_to_shipment, shipment, variant, 5)).to eq 5 + expect(subject.__send__(:add_to_shipment, shipment, variant, 5)).to eq 5 end end it 'should create inventory_units in the necessary states' do expect(shipment.stock_location).to receive(:fill_status).with(variant, 5).and_return([3, 2]) - expect(subject.send(:add_to_shipment, shipment, variant, 5)).to eq 5 + expect(subject.__send__(:add_to_shipment, shipment, variant, 5)).to eq 5 units = shipment.inventory_units.group_by(&:variant_id) units = units[variant.id].group_by(&:state) @@ -53,7 +53,7 @@ RSpec.describe Spree::OrderInventory do end it 'should create stock_movement' do - expect(subject.send(:add_to_shipment, shipment, variant, 5)).to eq 5 + expect(subject.__send__(:add_to_shipment, shipment, variant, 5)).to eq 5 stock_item = shipment.stock_location.stock_item(variant) movement = stock_item.stock_movements.last @@ -89,7 +89,7 @@ RSpec.describe Spree::OrderInventory do it "doesn't restock items" do expect(shipment.stock_location).not_to receive(:restock) - expect(subject.send(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 end end @@ -98,12 +98,12 @@ RSpec.describe Spree::OrderInventory do it "doesn't restock items" do expect(shipment.stock_location).not_to receive(:restock) - expect(subject.send(:remove_from_shipment, shipment, variant, 1, false)).to eq 1 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 1, false)).to eq 1 end end it 'should create stock_movement' do - expect(subject.send(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 stock_item = shipment.stock_location.stock_item(variant) movement = stock_item.stock_movements.last @@ -127,7 +127,7 @@ RSpec.describe Spree::OrderInventory do expect(shipment.inventory_units_for[1]).not_to receive(:destroy) expect(shipment.inventory_units_for[2]).to receive(:destroy) - expect(subject.send(:remove_from_shipment, shipment, variant, 2, true)).to eq 2 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 2, true)).to eq 2 end it 'should destroy unshipped units first' do @@ -143,7 +143,7 @@ RSpec.describe Spree::OrderInventory do expect(shipment.inventory_units_for[0]).not_to receive(:destroy) expect(shipment.inventory_units_for[1]).to receive(:destroy) - expect(subject.send(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 end it 'only attempts to destroy as many units as are eligible, and return amount destroyed' do @@ -159,14 +159,14 @@ RSpec.describe Spree::OrderInventory do expect(shipment.inventory_units_for[0]).not_to receive(:destroy) expect(shipment.inventory_units_for[1]).to receive(:destroy) - expect(subject.send(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 end it 'should destroy self if not inventory units remain' do allow(shipment.inventory_units).to receive_messages(count: 0) expect(shipment).to receive(:destroy) - expect(subject.send(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 + expect(subject.__send__(:remove_from_shipment, shipment, variant, 1, true)).to eq 1 end end end diff --git a/spec/models/spree/payment_spec.rb b/spec/models/spree/payment_spec.rb index be09f52539..e22e064b60 100644 --- a/spec/models/spree/payment_spec.rb +++ b/spec/models/spree/payment_spec.rb @@ -868,19 +868,19 @@ RSpec.describe Spree::Payment do let(:payment) { build_stubbed(:payment) } it "returns the parameter amount when given" do - expect(payment.send(:calculate_refund_amount, 123)).to be === 123.0 + expect(payment.__send__(:calculate_refund_amount, 123)).to be === 123.0 end it "refunds up to the value of the payment when the outstanding balance is larger" do allow(payment).to receive(:credit_allowed) { 123 } allow(payment).to receive(:order) { double(:order, outstanding_balance: 1000) } - expect(payment.send(:calculate_refund_amount)).to eq(123) + expect(payment.__send__(:calculate_refund_amount)).to eq(123) end it "refunds up to the outstanding balance of the order when the payment is larger" do allow(payment).to receive(:credit_allowed) { 1000 } allow(payment).to receive(:order) { double(:order, outstanding_balance: 123) } - expect(payment.send(:calculate_refund_amount)).to eq(123) + expect(payment.__send__(:calculate_refund_amount)).to eq(123) end end diff --git a/spec/models/spree/return_authorization_spec.rb b/spec/models/spree/return_authorization_spec.rb index 2d0c0df31c..8dd7b949e4 100644 --- a/spec/models/spree/return_authorization_spec.rb +++ b/spec/models/spree/return_authorization_spec.rb @@ -104,7 +104,7 @@ RSpec.describe Spree::ReturnAuthorization do context "force_positive_amount" do it "should ensure the amount is always positive" do return_authorization.amount = -10 - return_authorization.send :force_positive_amount + return_authorization.__send__ :force_positive_amount expect(return_authorization.amount).to eq 10 end end diff --git a/spec/models/tag_rule/filter_order_cycles_spec.rb b/spec/models/tag_rule/filter_order_cycles_spec.rb index c5fbbfe12a..da96f716e2 100644 --- a/spec/models/tag_rule/filter_order_cycles_spec.rb +++ b/spec/models/tag_rule/filter_order_cycles_spec.rb @@ -12,7 +12,7 @@ RSpec.describe TagRule::FilterOrderCycles, type: :model do end it "returns false" do - expect(tag_rule.send(:tags_match?, nil)).to be false + expect(tag_rule.__send__(:tags_match?, nil)).to be false end end @@ -25,7 +25,7 @@ RSpec.describe TagRule::FilterOrderCycles, type: :model do context "when the rule has no preferred exchange tags specified" do before { allow(tag_rule).to receive(:preferred_exchange_tags) { "" } } - it { expect(tag_rule.send(:tags_match?, exchange_object)).to be false } + it { expect(tag_rule.__send__(:tags_match?, exchange_object)).to be false } end context "when the rule has preferred exchange tags specified that match ANY exchange tags" do @@ -34,7 +34,7 @@ RSpec.describe TagRule::FilterOrderCycles, type: :model do "wholesale,some_tag,member" } } - it { expect(tag_rule.send(:tags_match?, exchange_object)).to be true } + it { expect(tag_rule.__send__(:tags_match?, exchange_object)).to be true } end context "when the rule has preferred exchange tags specified that match NO exchange tags" do @@ -43,7 +43,7 @@ RSpec.describe TagRule::FilterOrderCycles, type: :model do "wholesale,some_tag,some_other_tag" } } - it { expect(tag_rule.send(:tags_match?, exchange_object)).to be false } + it { expect(tag_rule.__send__(:tags_match?, exchange_object)).to be false } end end end diff --git a/spec/models/tag_rule/filter_payment_methods_spec.rb b/spec/models/tag_rule/filter_payment_methods_spec.rb index c7d88ad4ed..a371c38c04 100644 --- a/spec/models/tag_rule/filter_payment_methods_spec.rb +++ b/spec/models/tag_rule/filter_payment_methods_spec.rb @@ -8,7 +8,7 @@ RSpec.describe TagRule::FilterPaymentMethods, type: :model do describe "determining whether tags match for a given payment method" do context "when the payment method is nil" do it "returns false" do - expect(tag_rule.send(:tags_match?, nil)).to be false + expect(tag_rule.__send__(:tags_match?, nil)).to be false end end @@ -17,7 +17,7 @@ RSpec.describe TagRule::FilterPaymentMethods, type: :model do context "when the rule has no preferred payment method tags specified" do before { allow(tag_rule).to receive(:preferred_payment_method_tags) { "" } } - it { expect(tag_rule.send(:tags_match?, payment_method)).to be false } + it { expect(tag_rule.__send__(:tags_match?, payment_method)).to be false } end context "when the rule has preferred customer tags specified that match ANY customer tags" do @@ -26,7 +26,7 @@ RSpec.describe TagRule::FilterPaymentMethods, type: :model do "wholesale,some_tag,member" } } - it { expect(tag_rule.send(:tags_match?, payment_method)).to be true } + it { expect(tag_rule.__send__(:tags_match?, payment_method)).to be true } end context "when the rule has preferred customer tags specified that match NO customer tags" do @@ -35,7 +35,7 @@ RSpec.describe TagRule::FilterPaymentMethods, type: :model do "wholesale,some_tag,some_other_tag" } } - it { expect(tag_rule.send(:tags_match?, payment_method)).to be false } + it { expect(tag_rule.__send__(:tags_match?, payment_method)).to be false } end end end diff --git a/spec/models/tag_rule/filter_products_spec.rb b/spec/models/tag_rule/filter_products_spec.rb index ae844564c3..9b96c4b35d 100644 --- a/spec/models/tag_rule/filter_products_spec.rb +++ b/spec/models/tag_rule/filter_products_spec.rb @@ -8,7 +8,7 @@ RSpec.describe TagRule::FilterProducts, type: :model do describe "determining whether tags match for a given variant" do context "when the variant is nil" do it "returns false" do - expect(tag_rule.send(:tags_match?, nil)).to be false + expect(tag_rule.__send__(:tags_match?, nil)).to be false end end @@ -17,7 +17,7 @@ RSpec.describe TagRule::FilterProducts, type: :model do context "when the rule has no preferred variant tags specified" do before { allow(tag_rule).to receive(:preferred_variant_tags) { "" } } - it { expect(tag_rule.send(:tags_match?, variant_object)).to be false } + it { expect(tag_rule.__send__(:tags_match?, variant_object)).to be false } end context "when the rule has preferred variant tags specified that match ANY variant tags" do @@ -26,7 +26,7 @@ RSpec.describe TagRule::FilterProducts, type: :model do "wholesale,some_tag,member" } } - it { expect(tag_rule.send(:tags_match?, variant_object)).to be true } + it { expect(tag_rule.__send__(:tags_match?, variant_object)).to be true } end context "when the rule has preferred variant tags specified that match NO variant tags" do @@ -35,7 +35,7 @@ RSpec.describe TagRule::FilterProducts, type: :model do "wholesale,some_tag,some_other_tag" } } - it { expect(tag_rule.send(:tags_match?, variant_object)).to be false } + it { expect(tag_rule.__send__(:tags_match?, variant_object)).to be false } end end end diff --git a/spec/models/tag_rule/filter_shipping_methods_spec.rb b/spec/models/tag_rule/filter_shipping_methods_spec.rb index 7276059b8e..d7c8b37c39 100644 --- a/spec/models/tag_rule/filter_shipping_methods_spec.rb +++ b/spec/models/tag_rule/filter_shipping_methods_spec.rb @@ -8,7 +8,7 @@ RSpec.describe TagRule::FilterShippingMethods, type: :model do describe "determining whether tags match for a given shipping method" do context "when the shipping method is nil" do it "returns false" do - expect(tag_rule.send(:tags_match?, nil)).to be false + expect(tag_rule.__send__(:tags_match?, nil)).to be false end end @@ -19,7 +19,7 @@ RSpec.describe TagRule::FilterShippingMethods, type: :model do context "when the rule has no preferred shipping method tags specified" do before { allow(tag_rule).to receive(:preferred_shipping_method_tags) { "" } } - it { expect(tag_rule.send(:tags_match?, shipping_method)).to be false } + it { expect(tag_rule.__send__(:tags_match?, shipping_method)).to be false } end context "when rule has preferred customer tags specified that match ANY customer tags" do @@ -28,7 +28,7 @@ RSpec.describe TagRule::FilterShippingMethods, type: :model do "wholesale,some_tag,member" } } - it { expect(tag_rule.send(:tags_match?, shipping_method)).to be true } + it { expect(tag_rule.__send__(:tags_match?, shipping_method)).to be true } end context "when rule has preferred customer tags specified that match NO customer tags" do @@ -37,7 +37,7 @@ RSpec.describe TagRule::FilterShippingMethods, type: :model do "wholesale,some_tag,some_other_tag" } } - it { expect(tag_rule.send(:tags_match?, shipping_method)).to be false } + it { expect(tag_rule.__send__(:tags_match?, shipping_method)).to be false } end end end diff --git a/spec/services/cart_service_spec.rb b/spec/services/cart_service_spec.rb index 13b70a2bd7..f2f90ebab2 100644 --- a/spec/services/cart_service_spec.rb +++ b/spec/services/cart_service_spec.rb @@ -116,21 +116,21 @@ RSpec.describe CartService do variant_data = { variant_id: variant.id, quantity: 2 } expect(cart_service).to receive(:line_item_for_variant).with(variant).and_return(nil) - expect(cart_service.send(:varies_from_cart, variant_data, variant )).to be true + expect(cart_service.__send__(:varies_from_cart, variant_data, variant )).to be true end it "returns true when item is not in cart and a max_quantity is specified" do variant_data = { variant_id: variant.id, quantity: 0, max_quantity: 2 } expect(cart_service).to receive(:line_item_for_variant).with(variant).and_return(nil) - expect(cart_service.send(:varies_from_cart, variant_data, variant)).to be true + expect(cart_service.__send__(:varies_from_cart, variant_data, variant)).to be true end it "returns false when item is not in cart and no quantity or max_quantity are specified" do variant_data = { variant_id: variant.id, quantity: 0 } expect(cart_service).to receive(:line_item_for_variant).with(variant).and_return(nil) - expect(cart_service.send(:varies_from_cart, variant_data, variant)).to be false + expect(cart_service.__send__(:varies_from_cart, variant_data, variant)).to be false end it "returns true when quantity varies" do @@ -138,7 +138,7 @@ RSpec.describe CartService do line_item = double(:line_item, quantity: 1, max_quantity: nil) allow(cart_service).to receive(:line_item_for_variant) { line_item } - expect(cart_service.send(:varies_from_cart, variant_data, variant)).to be true + expect(cart_service.__send__(:varies_from_cart, variant_data, variant)).to be true end it "returns true when max_quantity varies" do @@ -146,7 +146,7 @@ RSpec.describe CartService do line_item = double(:line_item, quantity: 1, max_quantity: nil) allow(cart_service).to receive(:line_item_for_variant) { line_item } - expect(cart_service.send(:varies_from_cart, variant_data, variant)).to be true + expect(cart_service.__send__(:varies_from_cart, variant_data, variant)).to be true end it "returns false when max_quantity varies only in nil vs 0" do @@ -154,7 +154,7 @@ RSpec.describe CartService do line_item = double(:line_item, quantity: 1, max_quantity: nil) allow(cart_service).to receive(:line_item_for_variant) { line_item } - expect(cart_service.send(:varies_from_cart, variant_data, variant)).to be false + expect(cart_service.__send__(:varies_from_cart, variant_data, variant)).to be false end it "returns false when both are specified and neither varies" do @@ -162,7 +162,7 @@ RSpec.describe CartService do line_item = double(:line_item, quantity: 1, max_quantity: 2) allow(cart_service).to receive(:line_item_for_variant) { line_item } - expect(cart_service.send(:varies_from_cart, variant_data, variant)).to be false + expect(cart_service.__send__(:varies_from_cart, variant_data, variant)).to be false end end @@ -183,7 +183,7 @@ RSpec.describe CartService do expect(order).to receive_message_chain(:contents, :update_or_create). with(variant, { quantity:, max_quantity: nil }) - cart_service.send(:attempt_cart_add, variant, quantity) + cart_service.__send__(:attempt_cart_add, variant, quantity) end it "filters quantities through #final_quantities" do @@ -196,7 +196,7 @@ RSpec.describe CartService do expect(order).to receive_message_chain(:contents, :update_or_create). with(variant, { quantity: 5, max_quantity: 5 }) - cart_service.send(:attempt_cart_add, variant, quantity, quantity) + cart_service.__send__(:attempt_cart_add, variant, quantity, quantity) end it "removes variants which have become out of stock" do @@ -209,7 +209,7 @@ RSpec.describe CartService do expect(cart_service).to receive(:cart_add).with(variant, 123, 123).and_call_original expect(order).to receive_message_chain(:contents, :remove).with(variant) - cart_service.send(:attempt_cart_add, variant, quantity, quantity) + cart_service.__send__(:attempt_cart_add, variant, quantity, quantity) end end @@ -223,24 +223,24 @@ RSpec.describe CartService do context "getting quantity and max_quantity" do it "returns full amount when available" do - expect(cart_service.send(:final_quantities, v, 5, nil)). + expect(cart_service.__send__(:final_quantities, v, 5, nil)). to eq({ quantity: 5, max_quantity: nil }) end it "returns a limited amount when not entirely available" do - expect(cart_service.send(:final_quantities, v, 15, nil)). + expect(cart_service.__send__(:final_quantities, v, 15, nil)). to eq({ quantity: 10, max_quantity: nil }) end end context "when max_quantity is provided" do it "returns full amount when available" do - expect(cart_service.send(:final_quantities, v, 5, 6)). + expect(cart_service.__send__(:final_quantities, v, 5, 6)). to eq({ quantity: 5, max_quantity: 6 }) end it "also returns the full amount when not entirely available" do - expect(cart_service.send(:final_quantities, v, 15, 16)). + expect(cart_service.__send__(:final_quantities, v, 15, 16)). to eq({ quantity: 10, max_quantity: 16 }) end end @@ -252,12 +252,12 @@ RSpec.describe CartService do end it "does not limit quantity" do - expect(cart_service.send(:final_quantities, v, 15, nil)). + expect(cart_service.__send__(:final_quantities, v, 15, nil)). to eq({ quantity: 15, max_quantity: nil }) end it "does not limit max_quantity" do - expect(cart_service.send(:final_quantities, v, 15, 16)). + expect(cart_service.__send__(:final_quantities, v, 15, 16)). to eq({ quantity: 15, max_quantity: 16 }) end end @@ -268,13 +268,13 @@ RSpec.describe CartService do let(:variant) { double(:variant) } it "returns false and errors when order cycle is not provided" do - expect(cart_service.send(:check_order_cycle_provided)).to be false + expect(cart_service.__send__(:check_order_cycle_provided)).to be false expect(cart_service.errors.to_a).to eq(["Please choose an order cycle for this order."]) end it "returns true when order cycle is provided" do cart_service.instance_variable_set :@order_cycle, double(:order_cycle) - expect(cart_service.send(:check_order_cycle_provided)).to be true + expect(cart_service.__send__(:check_order_cycle_provided)).to be true end end @@ -293,14 +293,16 @@ RSpec.describe CartService do expect(order_cycle_distributed_variants).to receive(:available_variants) .and_return([variant]) - expect(cart_service.send(:check_variant_available_under_distribution, variant)).to be true + expect(cart_service.__send__(:check_variant_available_under_distribution, + variant)).to be true expect(cart_service.errors).to be_empty end it "delegates to OrderCycles::DistributedVariantsService, returns false - error otherwise" do expect(order_cycle_distributed_variants).to receive(:available_variants).and_return([]) - expect(cart_service.send(:check_variant_available_under_distribution, variant)).to be false + expect(cart_service.__send__(:check_variant_available_under_distribution, + variant)).to be false expect(cart_service.errors.to_a) .to eq(["That product is not available from the chosen distributor or order cycle."]) end diff --git a/spec/services/products_renderer_spec.rb b/spec/services/products_renderer_spec.rb index 170e7b4a2c..d951360e13 100644 --- a/spec/services/products_renderer_spec.rb +++ b/spec/services/products_renderer_spec.rb @@ -51,7 +51,7 @@ RSpec.describe ProductsRenderer do { q: { "#{ransack_param}": "apples" } } ) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_apples]) end @@ -68,7 +68,7 @@ RSpec.describe ProductsRenderer do { q: { with_properties: [property_organic.id, 999] } }) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_apples]) end @@ -79,7 +79,7 @@ RSpec.describe ProductsRenderer do search_param = { q: { "with_variants_supplier_properties" => [property_organic.id] } } products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, search_param) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_apples, product_cherries]) end @@ -96,7 +96,7 @@ RSpec.describe ProductsRenderer do } } products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, search_param) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_apples, product_banana_bread, product_doughnuts]) end @@ -118,7 +118,7 @@ RSpec.describe ProductsRenderer do products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, search_param) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_peach]) end @@ -132,7 +132,7 @@ RSpec.describe ProductsRenderer do search_param = { q: { "with_variants_supplier_properties" => [property_organic.id] } } products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, search_param) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_apples]) end @@ -152,7 +152,7 @@ RSpec.describe ProductsRenderer do { q: { with_properties: [property_organic.id] } }) - products = products_renderer.send(:products) + products = products_renderer.__send__(:products) expect(products).to eq([product_cherries, product_banana_bread, product_doughnuts]) end end @@ -215,7 +215,7 @@ RSpec.describe ProductsRenderer do inventory_items: [create(:inventory_item, enterprise: hub, visible: false)]) } let(:products_renderer) { ProductsRenderer.new(hub, oc, customer) } - let(:variants) { products_renderer.send(:variants_for_shop_by_id) } + let(:variants) { products_renderer.__send__(:variants_for_shop_by_id) } it "scopes variants to distribution" do expect(variants[p.id]).to include v1 diff --git a/spec/services/variant_units/option_value_namer_spec.rb b/spec/services/variant_units/option_value_namer_spec.rb index 8c2ac4f537..58ce97d246 100644 --- a/spec/services/variant_units/option_value_namer_spec.rb +++ b/spec/services/variant_units/option_value_namer_spec.rb @@ -45,7 +45,7 @@ module VariantUnits allow(v).to receive(:product) { p } subject = OptionValueNamer.new v - expect(subject.send(:value_scaled?)).to be true + expect(subject.__send__(:value_scaled?)).to be true end it "returns false otherwise" do @@ -54,7 +54,7 @@ module VariantUnits allow(v).to receive(:product) { p } subject = OptionValueNamer.new v - expect(subject.send(:value_scaled?)).to be false + expect(subject.__send__(:value_scaled?)).to be false end end @@ -72,7 +72,7 @@ module VariantUnits allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 100 } - expect(subject.send(:option_value_value_unit)).to eq [100, 'g'] + expect(subject.__send__(:option_value_value_unit)).to eq [100, 'g'] end it "generates values when unit value is non-integer" do @@ -81,7 +81,7 @@ module VariantUnits allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 123.45 } - expect(subject.send(:option_value_value_unit)).to eq [123.45, 'g'] + expect(subject.__send__(:option_value_value_unit)).to eq [123.45, 'g'] end it "returns a value of 1 when unit value equals the scale" do @@ -90,7 +90,7 @@ module VariantUnits allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 1000.0 } - expect(subject.send(:option_value_value_unit)).to eq [1, 'kg'] + expect(subject.__send__(:option_value_value_unit)).to eq [1, 'kg'] end it "returns only values that are in the same measurement systems" do @@ -100,7 +100,7 @@ module VariantUnits allow(v).to receive(:unit_value) { 500 } # 500g would convert to > 1 pound, but we don't want the namer to use # pounds since it's in a different measurement system. - expect(subject.send(:option_value_value_unit)).to eq [500, 'g'] + expect(subject.__send__(:option_value_value_unit)).to eq [500, 'g'] end it "generates values for all weight scales" do @@ -110,7 +110,7 @@ module VariantUnits allow(v).to receive(:product) { p } allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 10.0 * scale } - expect(subject.send(:option_value_value_unit)).to eq [10, unit] + expect(subject.__send__(:option_value_value_unit)).to eq [10, unit] end end @@ -120,7 +120,7 @@ module VariantUnits allow(v).to receive(:product) { p } allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 3 * scale } - expect(subject.send(:option_value_value_unit)).to eq [3, unit] + expect(subject.__send__(:option_value_value_unit)).to eq [3, unit] end end @@ -129,7 +129,7 @@ module VariantUnits allow(v).to receive(:product) { p } allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 0.0001 } - expect(subject.send(:option_value_value_unit)).to eq [0.1, 'mL'] + expect(subject.__send__(:option_value_value_unit)).to eq [0.1, 'mL'] end it "generates values for item units" do @@ -139,7 +139,7 @@ module VariantUnits allow(v).to receive(:product) { p } allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 100 } - expect(subject.send(:option_value_value_unit)).to eq [100, unit.pluralize] + expect(subject.__send__(:option_value_value_unit)).to eq [100, unit.pluralize] end end @@ -149,7 +149,7 @@ module VariantUnits allow(v).to receive(:product) { p } allow(p).to receive(:persisted?) { true } allow(v).to receive(:unit_value) { 1 } - expect(subject.send(:option_value_value_unit)).to eq [1, 'packet'] + expect(subject.__send__(:option_value_value_unit)).to eq [1, 'packet'] end it "returns [nil, nil] when unit value is not set" do @@ -157,7 +157,7 @@ module VariantUnits variant_unit_name: 'foo') allow(v).to receive(:product) { p } allow(v).to receive(:unit_value) { nil } - expect(subject.send(:option_value_value_unit)).to eq [nil, nil] + expect(subject.__send__(:option_value_value_unit)).to eq [nil, nil] end it "truncates value to 2 decimals maximum" do @@ -167,7 +167,7 @@ module VariantUnits allow(p).to receive(:persisted?) { true } # The unit_value is stored rounded to 2 decimals allow(v).to receive(:unit_value) { (12.5 * oz_scale).round(2) } - expect(subject.send(:option_value_value_unit)).to eq [BigDecimal(12.5, 6), 'oz'] + expect(subject.__send__(:option_value_value_unit)).to eq [BigDecimal(12.5, 6), 'oz'] end end end diff --git a/spec/support/localized_number_helper.rb b/spec/support/localized_number_helper.rb index 75e8803915..d05f5972b1 100644 --- a/spec/support/localized_number_helper.rb +++ b/spec/support/localized_number_helper.rb @@ -11,11 +11,11 @@ shared_examples "a model using the LocalizedNumber module" do |attributes| it "uses the LocalizedNumber.parse method when setting #{attribute}" do allow(Spree::LocalizedNumber).to receive(:parse).and_return(nil) expect(Spree::LocalizedNumber).to receive(:parse).with('1.599,99') - subject.send(setter, '1.599,99') + subject.__send__(setter, '1.599,99') end it "creates an error if the input to #{attribute} is invalid" do - subject.send(setter, '1.59,99') + subject.__send__(setter, '1.59,99') subject.valid? expect(subject.errors[attribute]).to include('has an invalid format. Please enter a number.') end @@ -36,9 +36,9 @@ shared_examples "a Spree Calculator model using the LocalizedNumber module" do | end it "does not modify the attribute value when it is invalid" do - subject.send(setter, 'invalid') + subject.__send__(setter, 'invalid') subject.valid? - expect(subject.send(attribute)).to eq 'invalid' + expect(subject.__send__(attribute)).to eq 'invalid' end end end