Skip to content

Commit b4cd830

Browse files
committed
move spree from pluginaweek/state_machine to state-machines/state_machines-activerecord
resolves pluginaweek/state_machine#310
1 parent 747817e commit b4cd830

File tree

10 files changed

+10
-37
lines changed

10 files changed

+10
-37
lines changed

api/app/controllers/spree/api/checkouts_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def next
1919
authorize! :update, @order, order_token
2020
@order.next!
2121
respond_with(@order, default_template: 'spree/api/orders/show', status: 200)
22-
rescue StateMachine::InvalidTransition
22+
rescue StateMachines::InvalidTransition
2323
respond_with(@order, default_template: 'spree/api/orders/could_not_transition', status: 422)
2424
end
2525

api/spec/spec_helper.rb

-15
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@
2020
puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`"
2121
exit
2222
end
23-
#
24-
# STATE MACHINE GEM HACK
25-
# Rails 4.1.0.rc1 and StateMachine don't play nice
26-
# https://github.com/pluginaweek/state_machine/issues/295
27-
require 'state_machine'
28-
require 'state_machine/version'
29-
30-
unless StateMachine::VERSION == '1.2.0'
31-
# If you see this message, please test removing this file
32-
# If it's still required, please bump up the version above
33-
puts "StateMachine Hack says: Please remove me, StateMachine version has changed #{__FILE__} #{__LINE__} "
34-
end
35-
module StateMachine::Integrations::ActiveModel
36-
public :around_validation
37-
end
3823

3924

4025

core/app/models/spree/inventory_unit.rb

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class InventoryUnit < ActiveRecord::Base
1717
end
1818

1919
# state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
20+
# comment updated 08/2017: see https://github.com/state-machines/state_machines
2021
state_machine initial: :on_hand do
2122
event :fill_backorder do
2223
transition to: :on_hand, from: :backordered

core/app/models/spree/order/checkout.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def self.define_state_machine!
3434
klass = self
3535

3636
# To avoid a ton of warnings when the state machine is re-defined
37-
StateMachine::Machine.ignore_method_conflicts = true
37+
StateMachines::Machine.ignore_method_conflicts = true
3838
# To avoid multiple occurrences of the same transition being defined
3939
# On first definition, state_machines will not be defined
4040
state_machines.clear if respond_to?(:state_machines)

core/app/models/spree/payment.rb

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def persist_invalid
4848
end
4949

5050
# order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
51+
# comment updated 08/2017: see https://github.com/state-machines/state_machines
5152
state_machine initial: :checkout do
5253
# With card payments, happens before purchase or authorization happens
5354
event :started_processing do

core/app/models/spree/shipment.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Shipment < ActiveRecord::Base
3030
scope :trackable, -> { where("tracking IS NOT NULL AND tracking != ''") }
3131

3232
# shipment state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
33+
# comment updated 08/2017: see https://github.com/state-machines/state_machines
3334
state_machine initial: :pending, use_transactions: false do
3435
event :ready do
3536
transition from: :pending, to: :ready, if: lambda { |shipment|
@@ -153,7 +154,7 @@ def discounted_cost
153154
alias discounted_amount discounted_cost
154155

155156
# Only one of either included_tax_total or additional_tax_total is set
156-
# This method returns the total of the two. Saves having to check if
157+
# This method returns the total of the two. Saves having to check if
157158
# tax is included or additional.
158159
def tax_total
159160
included_tax_total + additional_tax_total

core/lib/spree/core.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require 'paperclip'
1010
require 'paranoia'
1111
require 'ransack'
12-
require 'state_machine'
12+
require 'state_machines-activerecord'
1313
require 'friendly_id'
1414
require 'font-awesome-rails'
1515
require 'responders'

core/spec/models/spree/order/checkout_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def assert_state_changed(order, from, to)
9999

100100
it "cannot transition to address without any line items" do
101101
order.line_items.should be_blank
102-
lambda { order.next! }.should raise_error(StateMachine::InvalidTransition, /#{Spree.t(:there_are_no_items_for_this_order)}/)
102+
lambda { order.next! }.should raise_error(StateMachines::InvalidTransition, /#{Spree.t(:there_are_no_items_for_this_order)}/)
103103
end
104104

105105
context "from address" do
@@ -137,7 +137,7 @@ def assert_state_changed(order, from, to)
137137
context "if there are no shipping rates for any shipment" do
138138
specify do
139139
transition = lambda { order.next! }
140-
transition.should raise_error(StateMachine::InvalidTransition, /#{Spree.t(:items_cannot_be_shipped)}/)
140+
transition.should raise_error(StateMachines::InvalidTransition, /#{Spree.t(:items_cannot_be_shipped)}/)
141141
end
142142
end
143143
end

core/spec/spec_helper.rb

-15
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,9 @@
1515
# from the project root directory.
1616
ENV["RAILS_ENV"] ||= 'test'
1717

18-
# STATE MACHINE GEM HACK
19-
# Rails 4.1.0.rc1 and StateMachine don't play nice
20-
# https://github.com/pluginaweek/state_machine/issues/295
21-
require 'state_machine'
22-
require 'state_machine/version'
23-
24-
unless StateMachine::VERSION == '1.2.0'
25-
# If you see this message, please test removing this file
26-
# If it's still required, please bump up the version above
27-
puts "StateMachine Hack says: Please remove me, StateMachine version has changed #{__FILE__} #{__LINE__} "
28-
end
2918

3019
require 'byebug'
3120

32-
module StateMachine::Integrations::ActiveModel
33-
public :around_validation
34-
end
35-
3621
begin
3722
require File.expand_path("../dummy/config/environment", __FILE__)
3823
rescue LoadError

core/spree_core.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
3737
s.add_dependency 'rails', '~> 4.2.9'
3838
s.add_dependency 'ransack', '~> 1.4.1'
3939
s.add_dependency 'responders', '~> 2.3.0'
40-
s.add_dependency 'state_machine', '1.2.0'
40+
s.add_dependency 'state_machines-activerecord', '~> 0.5.0'
4141
s.add_dependency 'stringex', '~> 1.5.1'
4242
s.add_dependency 'truncate_html', '0.9.2'
4343
s.add_development_dependency 'byebug'

0 commit comments

Comments
 (0)