Sha256: 7c74b9b550c96f045339e6b514b905895d0b5dc758b144ce7d95d95e0c3695b1

Contents?: true

Size: 1003 Bytes

Versions: 48

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

Spree::Order.class_eval do
  attr_accessor :did_transition
end

module Spree
  describe OrdersController, type: :controller do
    # Regression test for https://github.com/spree/spree/issues/2004
    context "with a transition callback on first state" do
      let(:order) { Spree::Order.new }

      before do
        allow(controller).to receive_messages current_order: order
        expect(controller).to receive(:authorize!).at_least(:once).and_return(true)

        first_state, = Spree::Order.checkout_steps.first
        Spree::Order.state_machine.after_transition to: first_state do |order|
          order.did_transition = true
        end
      end

      it "correctly calls the transition callback" do
        expect(order.did_transition).to be_nil
        order.line_items << FactoryBot.create(:line_item)
        put :update, params: { checkout: "checkout" }
        expect(order.did_transition).to be true
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
solidus_frontend-2.10.5 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.10.3 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_starter_frontend-0.1.0 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.10.2 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.6 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.8.6 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.10.1 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.5 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.10.0 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.4 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.6.6 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.7.4 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.8.5 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.3 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.2 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.10.0.beta1 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.7.3 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.6.5 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.1 spec/controllers/spree/orders_controller_transitions_spec.rb
solidus_frontend-2.9.0 spec/controllers/spree/orders_controller_transitions_spec.rb