Commit Graph

22 Commits

Author SHA1 Message Date
Luis Ramos
2d7f1ce283 Delete all variants from test product not just the first one 2020-06-01 21:21:26 +01:00
Luis Ramos
be4104d6f3 Merge branch 'master' into 3-0-stable-may-5 2020-05-05 19:11:20 +01:00
Matt-Yorkley
a3757992b5 Use #tap to destroy and remove before block 2020-05-05 09:55:14 +02:00
Matt-Yorkley
f2cd122ec8 Update variant_stock_spec for unsaved and soft-deleted cases 2020-04-29 18:29:44 +02:00
Matt-Yorkley
c758cb5508 Fix expectations in order_shipment_spec
Some depreacted calls to #find_by_* had previously been updated elsewhere, but the spec was still checking if the object received the #find_by_shipping_method_id message.

Fixes:

  85) OrderShipment#select_shipping_method when order has a shipment when shipping_method_id is not valid for the order returns nil
      Failure/Error: expect(shipment.shipping_rates).to receive(:find_by_shipping_method_id).with(invalid_shipping_method_id) { nil }

        (#<ActiveRecord::Associations::CollectionProxy []>).find_by_shipping_method_id(1312)
            expected: 1 time with arguments: (1312)
            received: 0 times
      # ./spec/models/concerns/order_shipment_spec.rb:53:in `block (5 levels) in <top (required)>'
2020-02-26 11:50:51 +01:00
luisramos0
cd6d34663e Remove all usages of Spree Config track_inventory_levels, this is always true in OFN since v2.0.0 2019-09-22 15:25:24 +01:00
luisramos0
86b0d71c7e Result of rubocop auto-correct and rebuilding rubocop_manual_todo 2019-05-28 12:57:29 +01:00
luisramos0
12eab1bfa9 Merge variant_stock.count_on_hand into variant_stock.on_hand
variant.on_hand will not return infinity any longer if variant.on_demand is true. Clients of these methods will have to handle the combinations between on_hand and on_demand values
2019-02-18 22:00:16 +00:00
luisramos0
5d82efa213 Add unit test for VariantStock.can_supply? 2019-02-01 16:16:04 +00:00
Pau Pérez Fabregat
2b95b5e797 Merge pull request #3347 from luisramos0/2-0-default-on-demand
[Spree Upgrade] Sets StockLocation.backorderable_default to false in test factories
2019-01-21 17:34:46 +01:00
Pau Perez
a99a4725c9 Add #shipment to conform to OFN's decision
This ensures we can still use Order#shipment although Spree deprecates
it, while fixing a bug at the same time. The problem that was making the
test fail was on `Order#shipment` that Spree defines.

If the shipments association changes, `#shipment` returns stale data.
That is because the order object we might be using is still alive, and
so its @shipment ivar still holds an old shipment object (it's not nil)
and thus `@shipment ||= shipments.last` doesn't evaluate the right-hand
side of the expression.

Note that we need to `prepend` the evaluation of the concern (which it's
been rename) for our methods to take precedence over Spree ones. With
`include`, Spree's `#shipment` would still be picked up making the test
fail.
2019-01-18 16:02:51 +01:00
luisramos0
f896e78e6f Set StockLocation.backorderable_default to false in DefaultStockLocation and in StockLocation factory.
This makes the default value of variant.on_demand false in all environments and in tests.

Additionally, adapt VariantStock.on_demand test and product factory to this change (setting on_hand value in product factory so it's not out of stock by default).
2019-01-17 20:28:05 +00:00
Pau Perez
5b8c0dffe2 Remove test for a state that is no longer possible 2019-01-11 16:39:06 +01:00
luisramos0
66e69edca4 Rename ProductOnDemand to ProductStock; move product.on_hand into it; add product.on_demand; and remove unnecessary on_demand= 2018-12-12 12:10:25 +00:00
luisramos0
4f4fc00549 Improve code, specs and comments in the shipping_method selection process in the checkout controller 2018-12-09 20:05:10 +00:00
luisramos0
e23c4dda68 Add order_shipping_method specs to cover select_shipping_method 2018-11-30 12:58:27 +00:00
Pau Perez
de31823151 Add #on_demand= to make product creation page work
We're bringing in the setter that got removed in Spree 2.0 so that we
can still pass an on_demand value from the product creation form.

However, we won't keep the getter to keep things simple. The frontend
seems to be checking the existence of variants anyway, so then it can
also check for product.master.on_demand and we avoid some logic on the
backend.
2018-11-08 11:41:58 +00:00
Luis Ramos
0eb2854f8a Merge pull request #2680 from luisramos0/2-0-stable-x
[Spree Upgrade] Fixed inexistent order#shipping_method= in several specs
2018-09-24 15:07:04 +01:00
Pau Pérez Fabregat
99ba9d7d1b Merge branch '2-0-stable' into unit-test-variant-stock 2018-09-19 15:41:21 +02:00
Pau Perez
314ad5400f Move variant_stock.rb to concerns/ 2018-09-18 12:18:50 +02:00
luisramos0
fbd2d96b05 Moved shipment and shipping_method factories with flat rate and shipping fees to traits 2018-09-17 00:51:01 +01:00
luisramos0
3577f3790d Moved order.shipping_method to the OrderShippingMethod concern 2018-09-11 00:24:35 +01:00