app/controllers/spree/api/checkouts_controller.rb in solidus_api-2.10.5 vs app/controllers/spree/api/checkouts_controller.rb in solidus_api-2.11.0
- old
+ new
@@ -18,16 +18,12 @@
authorize! :update, @order, order_token
if !expected_total_ok?(params[:expected_total])
respond_with(@order, default_template: 'spree/api/orders/expected_total_mismatch', status: 400)
return
end
- authorize! :update, @order, order_token
@order.next!
respond_with(@order, default_template: 'spree/api/orders/show', status: 200)
- rescue StateMachines::InvalidTransition => error
- logger.error("invalid_transition #{error.event} from #{error.from} for #{error.object.class.name}. Error: #{error.inspect}")
- respond_with(@order, default_template: 'spree/api/orders/could_not_transition', status: 422)
end
def advance
authorize! :update, @order, order_token
@order.contents.advance
@@ -40,13 +36,10 @@
respond_with(@order, default_template: 'spree/api/orders/expected_total_mismatch', status: 400)
else
@order.complete!
respond_with(@order, default_template: 'spree/api/orders/show', status: 200)
end
- rescue StateMachines::InvalidTransition => error
- logger.error("invalid_transition #{error.event} from #{error.from} for #{error.object.class.name}. Error: #{error.inspect}")
- respond_with(@order, default_template: 'spree/api/orders/could_not_transition', status: 422)
end
def update
authorize! :update, @order, order_token
@@ -55,15 +48,12 @@
@order.associate_user!(Spree.user_class.find(user_id))
end
return if after_update_attributes
- if @order.completed? || @order.next
+ if @order.completed? || @order.next!
state_callback(:after)
respond_with(@order, default_template: 'spree/api/orders/show')
- else
- logger.error("failed_to_transition_errors=#{@order.errors.full_messages}")
- respond_with(@order, default_template: 'spree/api/orders/could_not_transition', status: 422)
end
else
invalid_resource!(@order)
end
end