Skip to content

Commit

Permalink
Delete dead code Checkout#find_transition
Browse files Browse the repository at this point in the history
This method is only called from tests and nowhere else in the codebase. We may as well remove it.
  • Loading branch information
Matt-Yorkley committed Jun 3, 2023
1 parent df02eba commit 4446dc9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
8 changes: 0 additions & 8 deletions app/models/spree/order/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions spec/models/spree/order/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 4446dc9

Please sign in to comment.