From 6e7ee02191d2a3b1c4e26c30e829a8dc55b4a316 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sat, 23 Jan 2021 11:14:22 +0000 Subject: [PATCH] Change spree.order_path to spree_order_path everywhere --- app/controllers/checkout_controller.rb | 6 +++--- .../spree/admin/payments_controller.rb | 2 +- app/controllers/spree/orders_controller.rb | 6 +++--- app/controllers/spree/paypal_controller.rb | 2 +- app/helpers/spree/orders_helper.rb | 2 +- .../spree/orders/form/_update_buttons.html.haml | 2 +- app/views/spree/shared/_order_details.html.haml | 2 +- .../checkout_controller_concurrency_spec.rb | 2 +- spec/controllers/checkout_controller_spec.rb | 4 ++-- spec/controllers/spree/orders_controller_spec.rb | 12 ++++++------ spec/features/consumer/account_spec.rb | 4 ++-- spec/features/consumer/shopping/orders_spec.rb | 16 ++++++++-------- spec/requests/checkout/paypal_spec.rb | 2 +- spec/requests/checkout/stripe_connect_spec.rb | 6 +++--- spec/requests/checkout/stripe_sca_spec.rb | 6 +++--- 15 files changed, 37 insertions(+), 37 deletions(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index ca7df8be49..5bc43e818f 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -142,7 +142,7 @@ class CheckoutController < ::BaseController def handle_redirect_from_stripe if OrderWorkflow.new(@order).next && order_complete? checkout_succeeded - redirect_to(spree.order_path(@order)) && return + redirect_to(spree_order_path(@order)) && return else checkout_failed end @@ -202,10 +202,10 @@ class CheckoutController < ::BaseController def update_succeeded_response respond_to do |format| format.html do - respond_with(@order, location: spree.order_path(@order)) + respond_with(@order, location: spree_order_path(@order)) end format.json do - render json: { path: spree.order_path(@order) }, status: :ok + render json: { path: spree_order_path(@order) }, status: :ok end end end diff --git a/app/controllers/spree/admin/payments_controller.rb b/app/controllers/spree/admin/payments_controller.rb index af913d50a8..8aacdc3b9c 100644 --- a/app/controllers/spree/admin/payments_controller.rb +++ b/app/controllers/spree/admin/payments_controller.rb @@ -153,7 +153,7 @@ module Spree def authorize_stripe_sca_payment return unless @payment.payment_method.class == Spree::Gateway::StripeSCA - @payment.authorize!(spree.order_path(@payment.order, only_path: false)) + @payment.authorize!(spree_order_path(@payment.order, only_path: false)) raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending? diff --git a/app/controllers/spree/orders_controller.rb b/app/controllers/spree/orders_controller.rb index 48e65ddbb1..dd53621567 100644 --- a/app/controllers/spree/orders_controller.rb +++ b/app/controllers/spree/orders_controller.rb @@ -85,7 +85,7 @@ module Spree @order.next_transition.run_callbacks if @order.cart? redirect_to checkout_state_path(@order.checkout_steps.first) elsif @order.complete? - redirect_to spree.order_path(@order) + redirect_to spree_order_path(@order) else redirect_to main_app.cart_path end @@ -152,7 +152,7 @@ module Spree else flash[:error] = I18n.t(:orders_could_not_cancel) end - redirect_to request.referer || spree.order_path(@order) + redirect_to request.referer || spree_order_path(@order) end private @@ -216,7 +216,7 @@ module Spree if items.empty? flash[:error] = I18n.t(:orders_cannot_remove_the_final_item) - redirect_to spree.order_path(order_to_update) + redirect_to spree_order_path(order_to_update) end end diff --git a/app/controllers/spree/paypal_controller.rb b/app/controllers/spree/paypal_controller.rb index 81f7433c22..48f032dad7 100644 --- a/app/controllers/spree/paypal_controller.rb +++ b/app/controllers/spree/paypal_controller.rb @@ -234,7 +234,7 @@ module Spree end def completion_route(order) - spree.order_path(order, token: order.token) + spree_order_path(order, token: order.token) end def address_required? diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index 9062689191..972e9f26b8 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -28,7 +28,7 @@ module Spree end def changeable_orders_link_path - changeable_orders.one? ? spree.order_path(changeable_orders.first) : spree.account_path + changeable_orders.one? ? spree_order_path(changeable_orders.first) : spree.account_path end def shop_changeable_orders_alert_html diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index 476e7d23d6..df73bfaae5 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -12,7 +12,7 @@ - if order.changes_allowed? .columns.show-for-medium-up.medium-3   .columns.small-12.medium-3 - = link_to spree.cancel_order_path(@order), method: :put, :class => "button secondary expand", "confirm-link-click" => t('orders_confirm_cancel') do + = link_to cancel_spree_order_path(@order), method: :put, :class => "button secondary expand", "confirm-link-click" => t('orders_confirm_cancel') do %i.ofn-i_009-close = t(:cancel_order) .columns.small-12.medium-3 diff --git a/app/views/spree/shared/_order_details.html.haml b/app/views/spree/shared/_order_details.html.haml index f4861d8148..425e6cacfc 100644 --- a/app/views/spree/shared/_order_details.html.haml +++ b/app/views/spree/shared/_order_details.html.haml @@ -41,7 +41,7 @@ = t(:orders_changeable_orders_alert_html, oc_close: l(order.order_cycle.orders_close_at, format: "%b %d, %Y %H:%M")) %a.close{ "ng-click" => "close()" } × - = form_for order, html: {id: 'update-order', name: 'update_order_form' } do |order_form| + = form_for order, url: spree_order_path, html: {id: 'update-order', name: 'update_order_form' } do |order_form| - if order.changes_allowed? = render 'spree/orders/form', order_form: order_form -else diff --git a/spec/controllers/checkout_controller_concurrency_spec.rb b/spec/controllers/checkout_controller_concurrency_spec.rb index 9d66c05a1f..12327ec747 100644 --- a/spec/controllers/checkout_controller_concurrency_spec.rb +++ b/spec/controllers/checkout_controller_concurrency_spec.rb @@ -82,7 +82,7 @@ describe CheckoutController, concurrency: true, type: :controller do # see the order page. This is basically verifying a "double click" # scenario. expect(response.status).to eq(200) - expect(response.body).to eq({ path: spree.order_path(order) }.to_json) + expect(response.body).to eq({ path: spree_order_path(order) }.to_json) expect(order.payments.count).to eq 1 expect(order.completed?).to be true end diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index d638789f6e..d55cbecf7e 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -110,7 +110,7 @@ describe CheckoutController, type: :controller do it "completes the order and redirects to the order confirmation page" do get :edit, { payment_intent: "pi_123" } expect(order.completed?).to be true - expect(response).to redirect_to spree.order_path(order) + expect(response).to redirect_to spree_order_path(order) end end end @@ -242,7 +242,7 @@ describe CheckoutController, type: :controller do spree_post :update, format: :json, order: {} expect(response.status).to eq(200) - expect(response.body).to eq({ path: spree.order_path(order) }.to_json) + expect(response.body).to eq({ path: spree_order_path(order) }.to_json) end it "returns an error on unexpected failure" do diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb index 8625195f2c..61e3cb41d6 100644 --- a/spec/controllers/spree/orders_controller_spec.rb +++ b/spec/controllers/spree/orders_controller_spec.rb @@ -68,12 +68,12 @@ describe Spree::OrdersController, type: :controller do let(:current_user) { nil } before do - request.env["PATH_INFO"] = spree.order_path(order) + request.env["PATH_INFO"] = spree_order_path(order) end it "redirects to unauthorized" do get :show, id: order.number - expect(response).to redirect_to(root_path(anchor: "login?after_login=#{spree.order_path(order)}")) + expect(response).to redirect_to(root_path(anchor: "login?after_login=#{spree_order_path(order)}")) expect(flash[:error]).to eq("Please log in to view your order.") end end @@ -318,7 +318,7 @@ describe Spree::OrdersController, type: :controller do it "removes the items" do spree_post :update, params expect(flash[:error]).to be nil - expect(response).to redirect_to spree.order_path(order) + expect(response).to redirect_to spree_order_path(order) expect(order.reload.line_items.count).to eq 1 end end @@ -329,7 +329,7 @@ describe Spree::OrdersController, type: :controller do it "does not remove items, flash suggests cancellation" do spree_post :update, params expect(flash[:error]).to eq I18n.t(:orders_cannot_remove_the_final_item) - expect(response).to redirect_to spree.order_path(order) + expect(response).to redirect_to spree_order_path(order) expect(order.reload.line_items.count).to eq 2 end end @@ -426,7 +426,7 @@ describe Spree::OrdersController, type: :controller do context "when the order is not yet complete" do it "responds with forbidden" do spree_put :cancel, params - expect(response.status).to redirect_to spree.order_path(order) + expect(response.status).to redirect_to spree_order_path(order) expect(flash[:error]).to eq I18n.t(:orders_could_not_cancel) end end @@ -440,7 +440,7 @@ describe Spree::OrdersController, type: :controller do it "responds with success" do spree_put :cancel, params - expect(response.status).to redirect_to spree.order_path(order) + expect(response.status).to redirect_to spree_order_path(order) expect(flash[:success]).to eq I18n.t(:orders_your_order_has_been_cancelled) end end diff --git a/spec/features/consumer/account_spec.rb b/spec/features/consumer/account_spec.rb index 84cb4e3731..dc13f1143b 100644 --- a/spec/features/consumer/account_spec.rb +++ b/spec/features/consumer/account_spec.rb @@ -85,8 +85,8 @@ feature ' visit '/account' expect(page).to have_content I18n.t('spree.users.orders.open_orders') - expect(page).to have_link d1o1.number, href: spree.order_path(d1o1) - expect(page).to have_link d1o2.number, href: spree.order_path(d1o2) + expect(page).to have_link d1o1.number, href: spree_order_path(d1o1) + expect(page).to have_link d1o2.number, href: spree_order_path(d1o2) expect(page).to have_link(distributor1.name, href: "#{distributor1.permalink}/shop", count: 2) expect(page).to have_link I18n.t('spree.users.open_orders.cancel'), href: spree.cancel_order_path(d1o1) diff --git a/spec/features/consumer/shopping/orders_spec.rb b/spec/features/consumer/shopping/orders_spec.rb index 980d51893d..829a83779a 100644 --- a/spec/features/consumer/shopping/orders_spec.rb +++ b/spec/features/consumer/shopping/orders_spec.rb @@ -44,16 +44,16 @@ feature "Order Management", js: true do it "allows the user to see the details" do # Cannot load the page without token - visit spree.order_path(order) + visit spree_order_path(order) expect(page).to_not be_confirmed_order_page # Can load the page with token - visit spree.order_path(order, token: order.token) + visit spree_order_path(order, token: order.token) expect(page).to be_confirmed_order_page # Can load the page even without the token, after loading the page with # token. - visit spree.order_path(order) + visit spree_order_path(order) expect(page).to be_confirmed_order_page end end @@ -66,7 +66,7 @@ feature "Order Management", js: true do end it "allows the user to see order details" do - visit spree.order_path(order) + visit spree_order_path(order) expect(page).to be_confirmed_order_page end end @@ -76,7 +76,7 @@ feature "Order Management", js: true do it "allows the user to see order details after login" do # Cannot load the page without signing in - visit spree.order_path(order) + visit spree_order_path(order) expect(page).to_not be_confirmed_order_page # Can load the page after signing in @@ -115,7 +115,7 @@ feature "Order Management", js: true do end it 'shows the name of the shipping method' do - visit spree.order_path(order) + visit spree_order_path(order) expect(find('#order')).to have_content(shipping_method.name) end @@ -125,7 +125,7 @@ feature "Order Management", js: true do end it "doesn't show form elements for editing the order" do - visit spree.order_path(order) + visit spree_order_path(order) expect(find("tr.variant-#{item1.variant.id}")).to have_content item1.product.name expect(find("tr.variant-#{item2.variant.id}")).to have_content item2.product.name expect(find("tr.variant-#{item3.variant.id}")).to have_content item3.product.name @@ -142,7 +142,7 @@ feature "Order Management", js: true do end it "allows quantity to be changed, items to be removed and the order to be cancelled" do - visit spree.order_path(order) + visit spree_order_path(order) expect(page).to have_button I18n.t(:order_saved), disabled: true expect(page).to have_no_button I18n.t(:save_changes) diff --git a/spec/requests/checkout/paypal_spec.rb b/spec/requests/checkout/paypal_spec.rb index e61bdb813c..e6cc446c0a 100644 --- a/spec/requests/checkout/paypal_spec.rb +++ b/spec/requests/checkout/paypal_spec.rb @@ -58,7 +58,7 @@ describe "checking out an order with a paypal express payment method", type: :re get spree.confirm_paypal_path, params # Processing was successful, order is complete - expect(response).to redirect_to spree.order_path(order, token: order.token) + expect(response).to redirect_to spree_order_path(order, token: order.token) expect(order.reload.complete?).to be true # We have only one payment, and one transaction fee diff --git a/spec/requests/checkout/stripe_connect_spec.rb b/spec/requests/checkout/stripe_connect_spec.rb index 50af6b975c..203409d1be 100644 --- a/spec/requests/checkout/stripe_connect_spec.rb +++ b/spec/requests/checkout/stripe_connect_spec.rb @@ -104,7 +104,7 @@ describe "checking out an order with a Stripe Connect payment method", type: :re it "should process the payment without storing card details" do put update_checkout_path, params - expect(json_response["path"]).to eq spree.order_path(order) + expect(json_response["path"]).to eq spree_order_path(order) expect(order.payments.completed.count).to be 1 card = order.payments.completed.first.source @@ -161,7 +161,7 @@ describe "checking out an order with a Stripe Connect payment method", type: :re it "should process the payment, and stores the card/customer details" do put update_checkout_path, params - expect(json_response["path"]).to eq spree.order_path(order) + expect(json_response["path"]).to eq spree_order_path(order) expect(order.payments.completed.count).to be 1 card = order.payments.completed.first.source @@ -263,7 +263,7 @@ describe "checking out an order with a Stripe Connect payment method", type: :re it "should process the payment, and keep the profile ids and other card details" do put update_checkout_path, params - expect(json_response["path"]).to eq spree.order_path(order) + expect(json_response["path"]).to eq spree_order_path(order) expect(order.payments.completed.count).to be 1 card = order.payments.completed.first.source diff --git a/spec/requests/checkout/stripe_sca_spec.rb b/spec/requests/checkout/stripe_sca_spec.rb index d1d959ff5f..c59bd3763d 100644 --- a/spec/requests/checkout/stripe_sca_spec.rb +++ b/spec/requests/checkout/stripe_sca_spec.rb @@ -130,7 +130,7 @@ describe "checking out an order with a Stripe SCA payment method", type: :reques it "should process the payment without storing card details" do put update_checkout_path, params - expect(json_response["path"]).to eq spree.order_path(order) + expect(json_response["path"]).to eq spree_order_path(order) expect(order.payments.completed.count).to be 1 card = order.payments.completed.first.source @@ -218,7 +218,7 @@ describe "checking out an order with a Stripe SCA payment method", type: :reques it "should process the payment, and store the card/customer details" do put update_checkout_path, params - expect(json_response["path"]).to eq spree.order_path(order) + expect(json_response["path"]).to eq spree_order_path(order) expect(order.payments.completed.count).to be 1 card = order.payments.completed.first.source @@ -303,7 +303,7 @@ describe "checking out an order with a Stripe SCA payment method", type: :reques it "should process the payment, and keep the profile ids and other card details" do put update_checkout_path, params - expect(json_response["path"]).to eq spree.order_path(order) + expect(json_response["path"]).to eq spree_order_path(order) expect(order.payments.completed.count).to be 1 card = order.payments.completed.first.source