From 8d5292c4ed5bf2832b38ea8092c95f7a6d6ef7a9 Mon Sep 17 00:00:00 2001 From: cyrillefr Date: Wed, 23 Apr 2025 16:11:22 +0200 Subject: [PATCH] Rename set method in spec helper and calls --- .rubocop_todo.yml | 3 +-- spec/requests/checkout/concurrency_spec.rb | 2 +- spec/requests/checkout/paypal_spec.rb | 2 +- spec/requests/checkout/routes_spec.rb | 2 +- spec/requests/checkout/stripe_sca_spec.rb | 2 +- spec/support/request/shop_workflow.rb | 2 +- .../system/consumer/checkout/backorder_spec.rb | 2 +- spec/system/consumer/checkout/details_spec.rb | 2 +- spec/system/consumer/checkout/guest_spec.rb | 2 +- spec/system/consumer/checkout/payment_spec.rb | 2 +- spec/system/consumer/checkout/summary_spec.rb | 2 +- spec/system/consumer/checkout/tax_incl_spec.rb | 4 ++-- .../consumer/checkout/tax_not_incl_spec.rb | 4 ++-- spec/system/consumer/multilingual_spec.rb | 4 ++-- spec/system/consumer/shopping/cart_spec.rb | 2 +- .../consumer/shopping/checkout_auth_spec.rb | 2 +- .../consumer/shopping/checkout_paypal_spec.rb | 2 +- .../consumer/shopping/checkout_stripe_spec.rb | 4 ++-- spec/system/consumer/shopping/products_spec.rb | 2 +- spec/system/consumer/shopping/shopping_spec.rb | 4 ++-- .../consumer/shopping/unit_price_spec.rb | 2 +- spec/system/consumer/white_label_spec.rb | 18 +++++++++--------- 22 files changed, 35 insertions(+), 36 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6f960ac65b..d0a55d7e21 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -221,10 +221,9 @@ Metrics/PerceivedComplexity: - 'app/models/spree/ability.rb' - 'app/models/spree/order/checkout.rb' -# Offense count: 2 +# Offense count: 1 Naming/AccessorMethodName: Exclude: - - 'spec/support/request/shop_workflow.rb' - 'spec/support/request/web_helper.rb' # Offense count: 1 diff --git a/spec/requests/checkout/concurrency_spec.rb b/spec/requests/checkout/concurrency_spec.rb index 58f8f0fb6f..0805531d3d 100644 --- a/spec/requests/checkout/concurrency_spec.rb +++ b/spec/requests/checkout/concurrency_spec.rb @@ -49,7 +49,7 @@ RSpec.describe "Concurrent checkouts", concurrency: true do order.next # => payment order.next # => confirmation - set_order(order) + pick_order(order) login_as(order.user) end diff --git a/spec/requests/checkout/paypal_spec.rb b/spec/requests/checkout/paypal_spec.rb index a32562835e..a5cbe87a8a 100644 --- a/spec/requests/checkout/paypal_spec.rb +++ b/spec/requests/checkout/paypal_spec.rb @@ -34,7 +34,7 @@ RSpec.describe "checking out an order with a paypal express payment method", typ expect(order.next).to be true # => address expect(order.next).to be true # => delivery expect(order.next).to be true # => payment - set_order order + pick_order order stub_paypal_confirm end diff --git a/spec/requests/checkout/routes_spec.rb b/spec/requests/checkout/routes_spec.rb index 55fe054662..9ae03183bb 100644 --- a/spec/requests/checkout/routes_spec.rb +++ b/spec/requests/checkout/routes_spec.rb @@ -31,7 +31,7 @@ RSpec.describe 'checkout endpoints', type: :request do allow(order_cycle_distributed_variants).to receive(:distributes_order_variants?) .and_return(true) - set_order order + pick_order order end context "when getting the cart `/checkout/cart`" do diff --git a/spec/requests/checkout/stripe_sca_spec.rb b/spec/requests/checkout/stripe_sca_spec.rb index 5640c49146..1fe468e85a 100644 --- a/spec/requests/checkout/stripe_sca_spec.rb +++ b/spec/requests/checkout/stripe_sca_spec.rb @@ -93,7 +93,7 @@ RSpec.describe "checking out an order with a Stripe SCA payment method", type: : Stripe.api_key = "sk_test_12345" order.update(distributor_id: enterprise.id, order_cycle_id: order_cycle.id) order.reload.update_totals - set_order order + pick_order order # Authorizes the payment stub_request(:post, "https://api.stripe.com/v1/payment_intents") diff --git a/spec/support/request/shop_workflow.rb b/spec/support/request/shop_workflow.rb index 3501e15ec9..7e52b000ac 100644 --- a/spec/support/request/shop_workflow.rb +++ b/spec/support/request/shop_workflow.rb @@ -33,7 +33,7 @@ module ShopWorkflow order_cycle.exchanges.outgoing.first.enterprise_fees << enterprise_fee end - def set_order(order) + def pick_order(order) allow_any_instance_of(ApplicationController).to receive(:session).and_return( order_id: order.id, access_token: order.token ) diff --git a/spec/system/consumer/checkout/backorder_spec.rb b/spec/system/consumer/checkout/backorder_spec.rb index 930e885a56..978ce4e9bc 100644 --- a/spec/system/consumer/checkout/backorder_spec.rb +++ b/spec/system/consumer/checkout/backorder_spec.rb @@ -11,7 +11,7 @@ RSpec.describe "Checkout" do before do variant.semantic_links << SemanticLink.new(semantic_id: "https://product") - set_order order + pick_order order login_as create(:user) end diff --git a/spec/system/consumer/checkout/details_spec.rb b/spec/system/consumer/checkout/details_spec.rb index bb204e3ca7..949abe9979 100644 --- a/spec/system/consumer/checkout/details_spec.rb +++ b/spec/system/consumer/checkout/details_spec.rb @@ -69,7 +69,7 @@ RSpec.describe "As a consumer, I want to checkout my order" do before do add_enterprise_fee enterprise_fee - set_order order + pick_order order distributor.shipping_methods.push(shipping_methods) end diff --git a/spec/system/consumer/checkout/guest_spec.rb b/spec/system/consumer/checkout/guest_spec.rb index f90f205298..c0780f7f63 100644 --- a/spec/system/consumer/checkout/guest_spec.rb +++ b/spec/system/consumer/checkout/guest_spec.rb @@ -74,7 +74,7 @@ RSpec.describe "As a consumer, I want to checkout my order" do before do add_enterprise_fee enterprise_fee - set_order order + pick_order order distributor.shipping_methods.push(shipping_methods) end diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index 0f3caddea8..d56d748666 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "As a consumer, I want to checkout my order" do before do add_enterprise_fee enterprise_fee - set_order order + pick_order order distributor.shipping_methods.push(free_shipping_with_required_address) end diff --git a/spec/system/consumer/checkout/summary_spec.rb b/spec/system/consumer/checkout/summary_spec.rb index 4ad66f422e..2ff1108f9f 100644 --- a/spec/system/consumer/checkout/summary_spec.rb +++ b/spec/system/consumer/checkout/summary_spec.rb @@ -39,7 +39,7 @@ RSpec.describe "As a consumer, I want to checkout my order" do before do add_enterprise_fee enterprise_fee - set_order order + pick_order order distributor.shipping_methods.push(free_shipping_with_required_address) end diff --git a/spec/system/consumer/checkout/tax_incl_spec.rb b/spec/system/consumer/checkout/tax_incl_spec.rb index de0ee1af4a..e3d2f780ed 100644 --- a/spec/system/consumer/checkout/tax_incl_spec.rb +++ b/spec/system/consumer/checkout/tax_incl_spec.rb @@ -86,7 +86,7 @@ RSpec.describe "As a consumer, I want to see adjustment breakdown" do describe "for a customer with shipping address within the tax zone" do before do - set_order order_within_zone + pick_order order_within_zone login_as(user_within_zone) end @@ -200,7 +200,7 @@ RSpec.describe "As a consumer, I want to see adjustment breakdown" do describe "for a customer with shipping address outside the tax zone" do before do - set_order order_outside_zone + pick_order order_outside_zone login_as(user_outside_zone) end diff --git a/spec/system/consumer/checkout/tax_not_incl_spec.rb b/spec/system/consumer/checkout/tax_not_incl_spec.rb index a5a0d26f91..be1f066761 100644 --- a/spec/system/consumer/checkout/tax_not_incl_spec.rb +++ b/spec/system/consumer/checkout/tax_not_incl_spec.rb @@ -92,7 +92,7 @@ RSpec.describe "As a consumer, I want to see adjustment breakdown" do describe "for a customer with shipping address within the tax zone" do before do - set_order order_within_zone + pick_order order_within_zone login_as(user_within_zone) end @@ -211,7 +211,7 @@ RSpec.describe "As a consumer, I want to see adjustment breakdown" do describe "for a customer with shipping address outside the tax zone" do before do - set_order order_outside_zone + pick_order order_outside_zone login_as(user_outside_zone) end diff --git a/spec/system/consumer/multilingual_spec.rb b/spec/system/consumer/multilingual_spec.rb index 16ec57b35c..a89ec41af0 100644 --- a/spec/system/consumer/multilingual_spec.rb +++ b/spec/system/consumer/multilingual_spec.rb @@ -51,7 +51,7 @@ RSpec.describe 'Multilingual' do let(:order) { create(:order, order_cycle:, distributor:) } before do - set_order order + pick_order order add_product_to_cart order, product, quantity: 1 end @@ -124,7 +124,7 @@ RSpec.describe 'Multilingual' do create(:order_ready_for_confirmation, distributor:) } before do - set_order order + pick_order order login_as user end diff --git a/spec/system/consumer/shopping/cart_spec.rb b/spec/system/consumer/shopping/cart_spec.rb index 0e40f3ea97..ed039bc28d 100644 --- a/spec/system/consumer/shopping/cart_spec.rb +++ b/spec/system/consumer/shopping/cart_spec.rb @@ -33,7 +33,7 @@ RSpec.describe "full-page cart" do let(:order) { create(:order, order_cycle:, distributor:) } before do - set_order order + pick_order order end describe "continue shopping" do diff --git a/spec/system/consumer/shopping/checkout_auth_spec.rb b/spec/system/consumer/shopping/checkout_auth_spec.rb index ed52e3ba19..1a8b41a053 100644 --- a/spec/system/consumer/shopping/checkout_auth_spec.rb +++ b/spec/system/consumer/shopping/checkout_auth_spec.rb @@ -25,7 +25,7 @@ RSpec.describe "As a consumer I want to check out my cart" do after { Warden.test_reset! } before do - set_order order + pick_order order add_product_to_cart order, product end diff --git a/spec/system/consumer/shopping/checkout_paypal_spec.rb b/spec/system/consumer/shopping/checkout_paypal_spec.rb index 93f2fdbabe..6f12e8a368 100644 --- a/spec/system/consumer/shopping/checkout_paypal_spec.rb +++ b/spec/system/consumer/shopping/checkout_paypal_spec.rb @@ -42,7 +42,7 @@ RSpec.describe "Check out with Paypal" do before do distributor.shipping_methods << free_shipping - set_order order + pick_order order add_product_to_cart order, product end diff --git a/spec/system/consumer/shopping/checkout_stripe_spec.rb b/spec/system/consumer/shopping/checkout_stripe_spec.rb index f1974fd5af..5d279f1d3b 100644 --- a/spec/system/consumer/shopping/checkout_stripe_spec.rb +++ b/spec/system/consumer/shopping/checkout_stripe_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "Check out with Stripe" do before do stripe_enable - set_order order + pick_order order add_product_to_cart order, product distributor.shipping_methods << [shipping_with_fee, free_shipping] end @@ -205,7 +205,7 @@ RSpec.describe "Check out with Stripe" do new_order = create(:order, user:, order_cycle:, distributor:, bill_address_id: nil, ship_address_id: nil) - set_order(new_order) + pick_order(new_order) add_product_to_cart(new_order, product, quantity: 10) stub_payment_intents_post_request order: new_order stub_successful_capture_request order: new_order diff --git a/spec/system/consumer/shopping/products_spec.rb b/spec/system/consumer/shopping/products_spec.rb index 87d155c0ec..179a43a08b 100644 --- a/spec/system/consumer/shopping/products_spec.rb +++ b/spec/system/consumer/shopping/products_spec.rb @@ -38,7 +38,7 @@ RSpec.describe "As a consumer I want to view products" do let(:order) { create(:order, distributor:) } before do - set_order order + pick_order order end describe "supplier's name is displayed" do diff --git a/spec/system/consumer/shopping/shopping_spec.rb b/spec/system/consumer/shopping/shopping_spec.rb index a7984c6318..def7ca7349 100644 --- a/spec/system/consumer/shopping/shopping_spec.rb +++ b/spec/system/consumer/shopping/shopping_spec.rb @@ -27,7 +27,7 @@ RSpec.describe "As a consumer I want to shop with a distributor" do let(:order) { create(:order, distributor:) } before do - set_order order + pick_order order end it "shows a distributor with images" do @@ -461,7 +461,7 @@ RSpec.describe "As a consumer I want to shop with a distributor" do before do add_variant_to_order_cycle(exchange, variant) set_order_cycle(order, oc1) - set_order(order) + pick_order(order) visit shop_path end diff --git a/spec/system/consumer/shopping/unit_price_spec.rb b/spec/system/consumer/shopping/unit_price_spec.rb index 95432649de..12159608e9 100644 --- a/spec/system/consumer/shopping/unit_price_spec.rb +++ b/spec/system/consumer/shopping/unit_price_spec.rb @@ -21,7 +21,7 @@ RSpec.describe "As a consumer, I want to check unit price information for a prod let(:user) { create(:user, password: "password", password_confirmation: "password") } before do - set_order order + pick_order order exchange1.update_attribute :pickup_time, "monday" add_variant_to_order_cycle(exchange1, variant) end diff --git a/spec/system/consumer/white_label_spec.rb b/spec/system/consumer/white_label_spec.rb index 25d9666c3c..82a14e1fd2 100644 --- a/spec/system/consumer/white_label_spec.rb +++ b/spec/system/consumer/white_label_spec.rb @@ -142,7 +142,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) end it_behaves_like "hides the OFN navigation when needed only" @@ -176,7 +176,7 @@ RSpec.describe 'White label setting' do context "when the user has a complete order" do before do - set_order(complete_order) + pick_order(complete_order) end shared_examples "hides the OFN navigation when needed only for the order confirmation" do @@ -225,7 +225,7 @@ RSpec.describe 'White label setting' do context "when the preference is set to false" do before do distributor.update_attribute(:hide_ofn_navigation, false) - set_order(order) + pick_order(order) allow_any_instance_of(EnterprisesHelper).to receive(:current_distributor). and_return(distributor) end @@ -288,7 +288,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) visit main_app.cart_path end @@ -299,7 +299,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) visit checkout_path end @@ -347,7 +347,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) visit main_app.cart_path end @@ -358,7 +358,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) visit checkout_path end @@ -399,7 +399,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) visit main_app.cart_path end @@ -410,7 +410,7 @@ RSpec.describe 'White label setting' do before do order.update_attribute(:state, 'cart') order.line_items << create(:line_item, variant: product.variants.first) - set_order(order) + pick_order(order) visit checkout_path end