1+ # frozen_string_literal: true
2+
13require "rails_helper"
24
35RSpec . describe "Integrating with the simple coordinator" do
9799 end
98100
99101 it 'raises exception and includes unfulfillable items' do
100- begin
101102 expect ( shipments ) . not_to be_empty
102- rescue Spree ::Order ::InsufficientStock => e
103+ rescue Spree ::Order ::InsufficientStock => e
103104 expect ( e . items . keys . map ( &:id ) ) . to contain_exactly ( variant . id )
104- end
105105 end
106106 end
107107
236236
237237 context "when custom coordinator options are passed" do
238238 let! ( :order ) {
239- create :order_with_line_items , line_items_attributes : [ { variant : create ( :product_in_stock ) . master } ]
239+ create :order_with_line_items , line_items_attributes : [ { variant : create ( :product_in_stock ) . master } ]
240240 }
241241
242242 subject {
243243 Spree ::Stock ::SimpleCoordinator . new ( order , coordinator_options :)
244244 }
245245
246246 describe "to customize the estimator's behavior" do
247- let ( :coordinator_options ) { { arbitrary_shipping_rates : [ my_shipping_rate ] } }
247+ let ( :coordinator_options ) { { arbitrary_shipping_rates : [ my_shipping_rate ] } }
248248 let ( :my_shipping_rate ) { create ( :shipping_method ) . shipping_rates . new }
249249
250250 around do |example |
251251 MyEstimator = Class . new ( Spree ::Stock ::Estimator ) do
252- def shipping_rates ( package , _frontend_only = true )
252+ def shipping_rates ( package )
253253 raise ShipmentRequired if package . shipment . nil?
254254 raise OrderRequired if package . shipment . order . nil?
255255
256256 first_shipping_rate = coordinator_options [ :arbitrary_shipping_rates ] &.first
257257
258258 if first_shipping_rate
259259 first_shipping_rate . selected = true
260- return [ first_shipping_rate ]
260+ [ first_shipping_rate ]
261261 else
262262 raise StandardError , "no shipping rate!"
263263 end
@@ -277,14 +277,14 @@ def shipping_rates(package, _frontend_only = true)
277277 end
278278
279279 describe "to customize the inventory unit builder's behavior" do
280- let ( :coordinator_options ) { { multiplier : 4 } }
280+ let ( :coordinator_options ) { { multiplier : 4 } }
281281
282282 around do |example |
283283 MyInventoryUnitBuilder = Class . new ( Spree ::Stock ::InventoryUnitBuilder ) do
284284 def units
285285 units = [ ]
286286 coordinator_options [ :multiplier ] . times do
287- units = units . concat ( super )
287+ units . concat ( super )
288288 end
289289 units
290290 end
@@ -305,7 +305,7 @@ def units
305305 end
306306
307307 describe "to customize the allocator's behavior" do
308- let ( :coordinator_options ) { { force_backordered : true } }
308+ let ( :coordinator_options ) { { force_backordered : true } }
309309
310310 around do |example |
311311 MyAllocator = Class . new ( Spree ::Stock ::Allocator ::OnHandFirst ) do
@@ -333,15 +333,17 @@ def allocate_inventory(desired)
333333 end
334334
335335 describe "to customize the stock locator filter behavior" do
336- let ( :coordinator_options ) { { force_specific_stock_location : specific_stock_location } }
336+ let ( :coordinator_options ) { { force_specific_stock_location : specific_stock_location } }
337337 let ( :specific_stock_location ) { create ( :stock_location ) }
338338
339339 around do |example |
340340 MyLocatorFilter = Class . new ( Spree ::Stock ::LocationFilter ::Active ) do
341341 def filter
342- coordinator_options [ :force_specific_stock_location ] ?
342+ if coordinator_options [ :force_specific_stock_location ]
343343 [ coordinator_options [ :force_specific_stock_location ] ]
344- : super
344+ else
345+ super
346+ end
345347 end
346348 end
347349
@@ -358,7 +360,7 @@ def filter
358360 end
359361
360362 describe "to customize the stock location sorters behavior" do
361- let ( :coordinator_options ) { { force_stock_location_order : [ stock_location_2 , stock_location_1 ] } }
363+ let ( :coordinator_options ) { { force_stock_location_order : [ stock_location_2 , stock_location_1 ] } }
362364 let! ( :stock_location_1 ) { create ( :stock_location , active : true , propagate_all_variants : true ) }
363365 let! ( :stock_location_2 ) { create ( :stock_location , active : true , propagate_all_variants : true ) }
364366
0 commit comments