From 4446dc922104e151a6c893a09a5dee8ceb75b7dc Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 2 Jun 2023 22:09:01 +0100 Subject: [PATCH] Delete dead code Checkout#find_transition This method is only called from tests and nowhere else in the codebase. We may as well remove it. --- app/models/spree/order/checkout.rb | 8 ------- spec/models/spree/order/checkout_spec.rb | 27 ------------------------ 2 files changed, 35 deletions(-) diff --git a/app/models/spree/order/checkout.rb b/app/models/spree/order/checkout.rb index 9e4d84f45926..3d1c41820fcd 100644 --- a/app/models/spree/order/checkout.rb +++ b/app/models/spree/order/checkout.rb @@ -96,14 +96,6 @@ def self.go_to_state(name, options = {}) end end - def self.find_transition(options = {}) - return nil if options.nil? || !options.include?(:from) || !options.include?(:to) - - next_event_transitions.detect do |transition| - transition[options[:from].to_sym] == options[:to].to_sym - end - end - def self.next_event_transitions @next_event_transitions ||= [] end diff --git a/spec/models/spree/order/checkout_spec.rb b/spec/models/spree/order/checkout_spec.rb index 69d46c1e4e79..02847257ea1c 100644 --- a/spec/models/spree/order/checkout_spec.rb +++ b/spec/models/spree/order/checkout_spec.rb @@ -6,33 +6,6 @@ let(:order) { Spree::Order.new } context "with default state machine" do - let(:transitions) do - [ - { address: :delivery }, - { delivery: :payment }, - { delivery: :confirmation }, - { payment: :confirmation }, - { confirmation: :complete } - ] - end - - it "has the following transitions" do - transitions.each do |transition| - transition = Spree::Order.find_transition(from: transition.keys.first, - to: transition.values.first) - expect(transition).to_not be_nil - end - end - - it "does not have a transition from delivery to confirm" do - transition = Spree::Order.find_transition(from: :delivery, to: :confirm) - expect(transition).to be_nil - end - - it '.find_transition when contract was broken' do - expect(Spree::Order.find_transition({ foo: :bar, baz: :dog })).to be_falsy - end - context "#checkout_steps" do context "when payment not required" do before { allow(order).to receive_messages payment_required?: false }