From 477336c6603f4ea88aa338fcfa072dd5a4549687 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 15 Mar 2024 12:17:48 +1100 Subject: [PATCH 1/3] Style RSpec/NotToNot --- .../spec/requests/enterprises_spec.rb | 2 +- .../spec/requests/persons_spec.rb | 2 +- .../stripe_sca_payment_authorize_spec.rb | 6 +- .../order_management/order/updater_spec.rb | 8 +- .../order_management/stock/package_spec.rb | 2 +- .../subscriptions/payment_setup_spec.rb | 2 +- .../subscriptions/proxy_order_syncer_spec.rb | 90 +++++++++---------- .../stripe_payment_setup_spec.rb | 8 +- .../subscriptions/summary_spec.rb | 4 +- .../subscriptions/validator_spec.rb | 44 ++++----- .../subscriptions/variants_list_spec.rb | 6 +- .../helpers/cookies_policy_helper_spec.rb | 4 +- spec/system/admin/orders_spec.rb | 12 +-- 13 files changed, 95 insertions(+), 95 deletions(-) diff --git a/engines/dfc_provider/spec/requests/enterprises_spec.rb b/engines/dfc_provider/spec/requests/enterprises_spec.rb index 766a2d3beb..587971a2ec 100644 --- a/engines/dfc_provider/spec/requests/enterprises_spec.rb +++ b/engines/dfc_provider/spec/requests/enterprises_spec.rb @@ -93,7 +93,7 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc: let(:other_enterprise) { create(:distributor_enterprise) } run_test! do - expect(response.body).to_not include "Apple" + expect(response.body).not_to include "Apple" end end end diff --git a/engines/dfc_provider/spec/requests/persons_spec.rb b/engines/dfc_provider/spec/requests/persons_spec.rb index 8e03a7667e..3af17b76e9 100644 --- a/engines/dfc_provider/spec/requests/persons_spec.rb +++ b/engines/dfc_provider/spec/requests/persons_spec.rb @@ -26,7 +26,7 @@ describe "Persons", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc: true let(:id) { other_user.id } run_test! do - expect(response.body).to_not include "dfc-b:Person" + expect(response.body).not_to include "dfc-b:Person" end end end diff --git a/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb b/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb index 9dd15e8a8b..afe866f15b 100644 --- a/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb +++ b/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb @@ -74,9 +74,9 @@ module OrderManagement payment_authorize.call! expect(order.errors.size).to eq 0 - expect(PaymentMailer).to_not have_received(:authorize_payment) - expect(PaymentMailer).to_not have_received(:authorization_required) - expect(mail_mock).to_not have_received(:deliver_now) + expect(PaymentMailer).not_to have_received(:authorize_payment) + expect(PaymentMailer).not_to have_received(:authorization_required) + expect(mail_mock).not_to have_received(:deliver_now) end context "when the processing is off-session (via backoffice/subscription)" do diff --git a/engines/order_management/spec/services/order_management/order/updater_spec.rb b/engines/order_management/spec/services/order_management/order/updater_spec.rb index 0447e84cb8..6c2542b9e0 100644 --- a/engines/order_management/spec/services/order_management/order/updater_spec.rb +++ b/engines/order_management/spec/services/order_management/order/updater_spec.rb @@ -237,7 +237,7 @@ module OrderManagement it "returns paid" do updater.update_payment_state - expect(order.payment_state).to_not eq("requires_authorization") + expect(order.payment_state).not_to eq("requires_authorization") end end @@ -362,7 +362,7 @@ module OrderManagement it "cancels unused payments requiring authorization" do expect(stripe_payment).to receive(:void_transaction!) - expect(cash_payment).to_not receive(:void_transaction!) + expect(cash_payment).not_to receive(:void_transaction!) order.updater.update_payment_state end @@ -416,7 +416,7 @@ module OrderManagement it "doesn't touch taxes" do allow(order).to receive(:completed?) { false } - expect(order).to_not receive(:create_tax_charge!) + expect(order).not_to receive(:create_tax_charge!) updater.__send__(:handle_legacy_taxes) end end @@ -439,7 +439,7 @@ module OrderManagement context "and the order has no legacy taxes" do it "leaves taxes untouched" do - expect(order).to_not receive(:create_tax_charge!) + expect(order).not_to receive(:create_tax_charge!) updater.__send__(:handle_legacy_taxes) end diff --git a/engines/order_management/spec/services/order_management/stock/package_spec.rb b/engines/order_management/spec/services/order_management/stock/package_spec.rb index 5f36592a67..64a9fd46d3 100644 --- a/engines/order_management/spec/services/order_management/stock/package_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/package_spec.rb @@ -168,7 +168,7 @@ module OrderManagement end it "does not return soft-deleted shipping methods" do - expect(package.shipping_methods).to_not include shipping_method3 + expect(package.shipping_methods).not_to include shipping_method3 end it "returns an empty array if distributor is nil" do diff --git a/engines/order_management/spec/services/order_management/subscriptions/payment_setup_spec.rb b/engines/order_management/spec/services/order_management/subscriptions/payment_setup_spec.rb index b646ea5222..035021eb49 100644 --- a/engines/order_management/spec/services/order_management/subscriptions/payment_setup_spec.rb +++ b/engines/order_management/spec/services/order_management/subscriptions/payment_setup_spec.rb @@ -42,7 +42,7 @@ module OrderManagement before { allow(order).to receive(:new_outstanding_balance) { 10 } } it "does nothing" do - expect{ payment_setup.call! }.to_not change { payment.amount }.from(10) + expect{ payment_setup.call! }.not_to change { payment.amount }.from(10) end end end diff --git a/engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb b/engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb index 510bf780e0..fcf06793df 100644 --- a/engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb +++ b/engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb @@ -10,8 +10,8 @@ module OrderManagement it "raises an error when initialized with an object that is not a Subscription or an ActiveRecord::Relation" do - expect{ ProxyOrderSyncer.new(subscription) }.to_not raise_error - expect{ ProxyOrderSyncer.new(Subscription.where(id: subscription.id)) }.to_not raise_error + expect{ ProxyOrderSyncer.new(subscription) }.not_to raise_error + expect{ ProxyOrderSyncer.new(Subscription.where(id: subscription.id)) }.not_to raise_error expect{ ProxyOrderSyncer.new("something") }.to raise_error RuntimeError end end @@ -70,8 +70,8 @@ module OrderManagement let!(:oc) { closed_oc } it "does not create a new proxy order for that oc" do - expect{ subscription.save! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ subscription.save! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end @@ -79,8 +79,8 @@ module OrderManagement let!(:oc) { open_oc_closes_before_begins_at_oc } it "does not create a new proxy order for that oc" do - expect{ subscription.save! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ subscription.save! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end @@ -99,8 +99,8 @@ module OrderManagement let!(:oc) { upcoming_closes_before_begins_at_oc } it "does not create a new proxy order for that oc" do - expect{ subscription.save! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ subscription.save! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end @@ -130,8 +130,8 @@ module OrderManagement let!(:oc) { upcoming_closes_after_ends_at_oc } it "does not create a new proxy order for that oc" do - expect{ subscription.save! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ subscription.save! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end end @@ -149,7 +149,7 @@ module OrderManagement context "the oc is closed (ie. closed before opens_at)" do let(:oc) { closed_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -157,7 +157,7 @@ module OrderManagement context "and the schedule includes an open oc that closes before begins_at" do let(:oc) { open_oc_closes_before_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -165,7 +165,7 @@ module OrderManagement context "and the oc is open and closes between begins_at and ends_at" do let(:oc) { open_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -173,7 +173,7 @@ module OrderManagement context "and the oc is upcoming and closes before begins_at" do let(:oc) { upcoming_closes_before_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -181,7 +181,7 @@ module OrderManagement context "and the oc is upcoming and closes on begins_at" do let(:oc) { upcoming_closes_on_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -189,7 +189,7 @@ module OrderManagement context "and the oc is upcoming and closes on ends_at" do let(:oc) { upcoming_closes_on_ends_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -197,7 +197,7 @@ module OrderManagement context "and the oc is upcoming and closes after ends_at" do let(:oc) { upcoming_closes_after_ends_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -209,7 +209,7 @@ module OrderManagement it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -218,7 +218,7 @@ module OrderManagement it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -238,7 +238,7 @@ module OrderManagement let(:oc) { open_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -247,7 +247,7 @@ module OrderManagement let(:oc) { upcoming_closes_on_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -256,7 +256,7 @@ module OrderManagement let(:oc) { upcoming_closes_on_ends_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -267,7 +267,7 @@ module OrderManagement it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -276,7 +276,7 @@ module OrderManagement it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end end @@ -297,7 +297,7 @@ module OrderManagement context "the oc is closed (ie. closed before opens_at)" do let(:oc) { closed_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -305,7 +305,7 @@ module OrderManagement context "and the schedule includes an open oc that closes before begins_at" do let(:oc) { open_oc_closes_before_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -313,7 +313,7 @@ module OrderManagement context "and the oc is open and closes between begins_at and ends_at" do let(:oc) { open_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -321,7 +321,7 @@ module OrderManagement context "and the oc is upcoming and closes before begins_at" do let(:oc) { upcoming_closes_before_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -329,7 +329,7 @@ module OrderManagement context "and the oc is upcoming and closes on begins_at" do let(:oc) { upcoming_closes_on_begins_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -337,7 +337,7 @@ module OrderManagement context "and the oc is upcoming and closes on ends_at" do let(:oc) { upcoming_closes_on_ends_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -345,7 +345,7 @@ module OrderManagement context "and the oc is upcoming and closes after ends_at" do let(:oc) { upcoming_closes_after_ends_at_oc } it "keeps the proxy order" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(1) + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(1) expect(proxy_orders).to include proxy_order end end @@ -357,7 +357,7 @@ module OrderManagement let(:oc) { closed_oc } it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -366,7 +366,7 @@ module OrderManagement let(:oc) { open_oc } it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -374,7 +374,7 @@ module OrderManagement let(:oc) { upcoming_closes_before_begins_at_oc } it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -382,7 +382,7 @@ module OrderManagement let(:oc) { upcoming_closes_on_begins_at_oc } it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -390,7 +390,7 @@ module OrderManagement let(:oc) { upcoming_closes_on_ends_at_oc } it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end @@ -398,7 +398,7 @@ module OrderManagement let(:oc) { upcoming_closes_after_ends_at_oc } it "removes the proxy order" do expect{ syncer.sync! }.to change { ProxyOrder.count }.from(1).to(0) - expect(proxy_orders).to_not include proxy_order + expect(proxy_orders).not_to include proxy_order end end end @@ -421,8 +421,8 @@ module OrderManagement let!(:oc) { closed_oc } it "does not create a new proxy order for that oc" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end @@ -430,8 +430,8 @@ module OrderManagement let(:oc) { open_oc_closes_before_begins_at_oc } it "does not create a new proxy order for that oc" do - expect{ subscription.save! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ subscription.save! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end @@ -448,8 +448,8 @@ module OrderManagement let!(:oc) { upcoming_closes_before_begins_at_oc } it "does not create a new proxy order for that oc" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end @@ -475,8 +475,8 @@ module OrderManagement let!(:oc) { upcoming_closes_after_ends_at_oc } it "does not create a new proxy order for that oc" do - expect{ syncer.sync! }.to_not change { ProxyOrder.count }.from(0) - expect(order_cycles).to_not include oc + expect{ syncer.sync! }.not_to change { ProxyOrder.count }.from(0) + expect(order_cycles).not_to include oc end end end diff --git a/engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb b/engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb index 8e9b063f3c..9c4e97157c 100644 --- a/engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb +++ b/engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb @@ -28,7 +28,7 @@ module OrderManagement let(:payment_method) { create(:payment_method) } it "returns the pending payment with no change" do - expect(payment).to_not receive(:update) + expect(payment).not_to receive(:update) expect(payment_setup.call!).to eq payment end end @@ -38,7 +38,7 @@ module OrderManagement context "and the card is already set (the payment source is a credit card)" do it "returns the pending payment with no change" do - expect(payment).to_not receive(:update) + expect(payment).not_to receive(:update) expect(payment_setup.call!).to eq payment end end @@ -54,7 +54,7 @@ module OrderManagement it "adds an error to the order and does not update the payment" do payment_setup.call! - expect(payment).to_not receive(:update) + expect(payment).not_to receive(:update) expect(payment_setup.call!).to eq payment expect(order.errors[:base].first).to eq "There are no authorised " \ "credit cards available to charge" @@ -80,7 +80,7 @@ module OrderManagement it "adds an error to the order and does not update the payment" do payment_setup.call! - expect(payment).to_not receive(:update) + expect(payment).not_to receive(:update) expect(payment_setup.call!).to eq payment expect(order.errors[:base].first).to eq "There are no authorised " \ "credit cards available to charge" diff --git a/engines/order_management/spec/services/order_management/subscriptions/summary_spec.rb b/engines/order_management/spec/services/order_management/subscriptions/summary_spec.rb index dcfd214008..6aeb292bf2 100644 --- a/engines/order_management/spec/services/order_management/subscriptions/summary_spec.rb +++ b/engines/order_management/spec/services/order_management/subscriptions/summary_spec.rb @@ -121,7 +121,7 @@ module OrderManagement it "returns orders specified by unrecorded_ids" do expect(orders).to include order1 - expect(orders).to_not include order2 + expect(orders).not_to include order2 end end @@ -130,7 +130,7 @@ module OrderManagement it "returns orders specified by the relevant issue hash" do expect(orders).to include order2 - expect(orders).to_not include order1 + expect(orders).not_to include order1 end end end diff --git a/engines/order_management/spec/services/order_management/subscriptions/validator_spec.rb b/engines/order_management/spec/services/order_management/subscriptions/validator_spec.rb index 6df7740d4e..55e4d28944 100644 --- a/engines/order_management/spec/services/order_management/subscriptions/validator_spec.rb +++ b/engines/order_management/spec/services/order_management/subscriptions/validator_spec.rb @@ -74,7 +74,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:shipping_method]).to_not be_empty + expect(validator.errors[:shipping_method]).not_to be_empty end end @@ -89,7 +89,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:shipping_method]).to_not be_empty + expect(validator.errors[:shipping_method]).not_to be_empty end end @@ -115,7 +115,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:payment_method]).to_not be_empty + expect(validator.errors[:payment_method]).not_to be_empty end end @@ -130,7 +130,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:payment_method]).to_not be_empty + expect(validator.errors[:payment_method]).not_to be_empty end end @@ -164,7 +164,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:payment_method]).to_not be_empty + expect(validator.errors[:payment_method]).not_to be_empty end end @@ -192,7 +192,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:begins_at]).to_not be_empty + expect(validator.errors[:begins_at]).not_to be_empty end end @@ -213,7 +213,7 @@ module OrderManagement let(:ends_at) { Time.zone.today } it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:ends_at]).to_not be_empty + expect(validator.errors[:ends_at]).not_to be_empty end end @@ -221,7 +221,7 @@ module OrderManagement let(:ends_at) { Time.zone.today - 1.day } it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:ends_at]).to_not be_empty + expect(validator.errors[:ends_at]).not_to be_empty end end @@ -249,8 +249,8 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:bill_address]).to_not be_empty - expect(validator.errors[:ship_address]).to_not be_empty + expect(validator.errors[:bill_address]).not_to be_empty + expect(validator.errors[:ship_address]).not_to be_empty end end @@ -276,7 +276,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:customer]).to_not be_empty + expect(validator.errors[:customer]).not_to be_empty end end @@ -288,7 +288,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:customer]).to_not be_empty + expect(validator.errors[:customer]).not_to be_empty end end @@ -313,7 +313,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:schedule]).to_not be_empty + expect(validator.errors[:schedule]).not_to be_empty end end @@ -325,7 +325,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:schedule]).to_not be_empty + expect(validator.errors[:schedule]).not_to be_empty end end @@ -371,7 +371,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:payment_method]).to_not be_empty + expect(validator.errors[:payment_method]).not_to be_empty end end @@ -383,7 +383,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:payment_method]).to_not be_empty + expect(validator.errors[:payment_method]).not_to be_empty end end @@ -395,7 +395,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:payment_method]).to_not be_empty + expect(validator.errors[:payment_method]).not_to be_empty end end @@ -428,7 +428,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:subscription_line_items]).to_not be_empty + expect(validator.errors[:subscription_line_items]).not_to be_empty end end @@ -441,7 +441,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:subscription_line_items]).to_not be_empty + expect(validator.errors[:subscription_line_items]).not_to be_empty end end @@ -468,7 +468,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:subscription_line_items]).to_not be_empty + expect(validator.errors[:subscription_line_items]).not_to be_empty end end @@ -480,7 +480,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:subscription_line_items]).to_not be_empty + expect(validator.errors[:subscription_line_items]).not_to be_empty end end end @@ -538,7 +538,7 @@ module OrderManagement it "adds an error and returns false" do expect(validator.valid?).to be false - expect(validator.errors[:subscription_line_items]).to_not be_empty + expect(validator.errors[:subscription_line_items]).not_to be_empty end end diff --git a/engines/order_management/spec/services/order_management/subscriptions/variants_list_spec.rb b/engines/order_management/spec/services/order_management/subscriptions/variants_list_spec.rb index 0e00df50df..dc51f14f8e 100644 --- a/engines/order_management/spec/services/order_management/subscriptions/variants_list_spec.rb +++ b/engines/order_management/spec/services/order_management/subscriptions/variants_list_spec.rb @@ -66,7 +66,7 @@ module OrderManagement } it "is not eligible" do - expect(described_class.eligible_variants(shop)).to_not include(variant) + expect(described_class.eligible_variants(shop)).not_to include(variant) end end @@ -106,7 +106,7 @@ module OrderManagement context "if the variant is unrelated" do it "is not eligible" do - expect(described_class.eligible_variants(shop)).to_not include(variant) + expect(described_class.eligible_variants(shop)).not_to include(variant) end end end @@ -154,7 +154,7 @@ module OrderManagement context "if the variant is unrelated" do it "is false" do - expect(described_class).to_not be_in_open_and_upcoming_order_cycles(shop, + expect(described_class).not_to be_in_open_and_upcoming_order_cycles(shop, schedule, variant) end diff --git a/engines/web/spec/helpers/cookies_policy_helper_spec.rb b/engines/web/spec/helpers/cookies_policy_helper_spec.rb index 6807786a36..02ff9910a0 100644 --- a/engines/web/spec/helpers/cookies_policy_helper_spec.rb +++ b/engines/web/spec/helpers/cookies_policy_helper_spec.rb @@ -24,13 +24,13 @@ module Web end scenario "is not equal to the matomo URL" do - expect(helper.matomo_iframe_src).to_not eq Spree::Config.matomo_url + expect(helper.matomo_iframe_src).not_to eq Spree::Config.matomo_url end end scenario "is not nil, when matomo url is nil" do Spree::Config.matomo_url = nil - expect(helper.matomo_iframe_src).to_not eq nil + expect(helper.matomo_iframe_src).not_to eq nil end end diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 7a08a82974..9bcda2b2ee 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -652,11 +652,11 @@ describe ' invoice_content = extract_pdf_content expect(invoice_content).to have_content("TAX INVOICE", count: 1) - expect(invoice_content).to_not have_content(order4.number.to_s) + expect(invoice_content).not_to have_content(order4.number.to_s) expect(invoice_content).to have_content(order5.number.to_s) - expect(invoice_content).to_not have_content(distributor4.name.to_s) + expect(invoice_content).not_to have_content(distributor4.name.to_s) expect(invoice_content).to have_content(distributor5.name.to_s) - expect(invoice_content).to_not have_content(order_cycle4.name.to_s) + expect(invoice_content).not_to have_content(order_cycle4.name.to_s) expect(invoice_content).to have_content(order_cycle5.name.to_s) end end @@ -728,11 +728,11 @@ describe ' within ".ofn-drop-down .menu" do expect { page.find("span", text: "Print Invoices").click # Prints invoices in bulk - }.to_not enqueue_job(BulkInvoiceJob) + }.not_to enqueue_job(BulkInvoiceJob) end - expect(page).to_not have_content "Compiling Invoices" - expect(page).to_not have_content "Please wait until the PDF is ready " \ + expect(page).not_to have_content "Compiling Invoices" + expect(page).not_to have_content "Please wait until the PDF is ready " \ "before closing this modal." expect(page).to have_content "#{ From 931ee2f9d22d7ff66e43af7fd12272d678370903 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 15 Mar 2024 12:40:00 +1100 Subject: [PATCH 2/3] Style Style/RedundantLineContinuation --- lib/open_food_network/order_cycle_permissions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/open_food_network/order_cycle_permissions.rb b/lib/open_food_network/order_cycle_permissions.rb index 7568ff970e..a20a6292e2 100644 --- a/lib/open_food_network/order_cycle_permissions.rb +++ b/lib/open_food_network/order_cycle_permissions.rb @@ -105,9 +105,9 @@ module OpenFoodNetwork where("spree_products.id IN (?)", product_ids).pluck(:id).uniq end - ids = managed_permitted_ids | hubs_permitted_ids | hubs_permitting_ids \ - | producers_permitted_ids | producers_permitting_ids | managed_active_ids \ - | hubs_active_ids | producers_active_ids + ids = managed_permitted_ids | hubs_permitted_ids | hubs_permitting_ids | + producers_permitted_ids | producers_permitting_ids | + managed_active_ids | hubs_active_ids | producers_active_ids Enterprise.where(id: ids) end From 7abe455899337ee43b105eff8dd7be99cb5c722e Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 15 Mar 2024 12:52:09 +1100 Subject: [PATCH 3/3] Exclude false Style/RedundantLineContinuation file The current Rubocop version flags good code as bad. Regenerating the todo file added it there and when the issue is fixed it will disappear from our generated todo list as well. --- .rubocop_todo.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 250bf7c60f..00b861c123 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp` -# using RuboCop version 1.60.2. +# using RuboCop version 1.62.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -113,6 +113,7 @@ Lint/SelfAssignment: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. Lint/UselessMethodDefinition: Exclude: - 'app/models/spree/gateway.rb' @@ -602,14 +603,6 @@ Rails/SkipsModelValidations: - 'app/models/variant_override.rb' - 'spec/models/spree/line_item_spec.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Rails/SquishedSQLHeredocs: - Exclude: - - 'app/queries/customers_with_balance.rb' - - 'app/queries/outstanding_balance.rb' - - 'spec/queries/outstanding_balance_spec.rb' - # Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -656,7 +649,7 @@ Rails/UnusedRenderContent: - 'app/controllers/api/v0/taxons_controller.rb' - 'app/controllers/api/v0/variants_controller.rb' -# Offense count: 55 +# Offense count: 54 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/WhereEquals: Exclude: @@ -678,7 +671,6 @@ Rails/WhereEquals: - 'app/models/spree/shipping_method.rb' - 'app/models/spree/variant.rb' - 'app/models/subscription.rb' - - 'app/queries/payments_requiring_action.rb' - 'app/serializers/api/enterprise_shopfront_serializer.rb' - 'app/serializers/api/order_serializer.rb' - 'lib/open_food_network/enterprise_fee_calculator.rb' @@ -883,7 +875,7 @@ Style/PreferredHashMethods: Exclude: - 'app/controllers/api/v0/shipments_controller.rb' -# Offense count: 3 +# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. Style/RedundantArgument: @@ -898,7 +890,7 @@ Style/RedundantAssignment: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowComments. +# Configuration parameters: AutoCorrect, AllowComments. Style/RedundantInitialize: Exclude: - 'spec/models/spree/gateway_spec.rb' @@ -910,6 +902,12 @@ Style/RedundantInterpolation: - 'lib/tasks/karma.rake' - 'spec/base_spec_helper.rb' +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantLineContinuation: + Exclude: + - 'lib/reporting/reports/enterprise_fee_summary/scope.rb' + # Offense count: 19 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns.