File tree 4 files changed +33
-2
lines changed
lib/shopify_api/resources
4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def total_inventory=(new_value)
22
22
end
23
23
24
24
def serializable_hash ( options = { } )
25
- should_include_inventory_params ? super ( options ) : super ( options ) . except ( " total_inventory" )
25
+ should_include_inventory_params ? super ( options ) : super ( options ) . except ( ' total_inventory' )
26
26
end
27
27
28
28
def collections
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def old_inventory_quantity=(new_value)
21
21
end
22
22
23
23
def serializable_hash ( options = { } )
24
- should_include_inventory_params ? super ( options ) : super ( options ) . except ( " inventory_quantity" , " old_inventory_quantity" )
24
+ should_include_inventory_params ? super ( options ) : super ( options ) . except ( ' inventory_quantity' , ' old_inventory_quantity' )
25
25
end
26
26
27
27
private
Original file line number Diff line number Diff line change @@ -58,6 +58,23 @@ def test_price_range_when_has_different_price
58
58
assert_equal ( '100.00 - 199.00' , @product . price_range )
59
59
end
60
60
61
+ def test_deprecated_variant_inventory_fields_are_included_in_2019_07
62
+ ShopifyAPI ::Base . api_version = '2019-07'
63
+ variant = @product . variants . first
64
+ assert variant . as_json . include? ( 'inventory_quantity' )
65
+ end
66
+
67
+ def test_deprecated_variant_inventory_fields_are_removed_in_2020_01
68
+ ShopifyAPI ::Base . api_version = '2020-01'
69
+ variant = @product . variants . first
70
+ refute variant . as_json . include? ( 'inventory_quantity' )
71
+ end
72
+
73
+ def test_deprecated_inventory_fields_are_removed_in_2020_01
74
+ ShopifyAPI ::Base . api_version = '2020-01'
75
+ refute @product . as_json . include? ( 'total_inventory' )
76
+ end
77
+
61
78
def test_setting_product_total_inventory_passes_in_api_before_2019_10
62
79
ShopifyAPI ::Base . api_version = '2019-07'
63
80
fake ( "products/632910392" , { :body => load_fixture ( 'product' ) } )
Original file line number Diff line number Diff line change @@ -44,6 +44,20 @@ def test_delete_variant
44
44
assert v . destroy
45
45
end
46
46
47
+ def test_deprecated_inventory_fields_are_included_in_2019_07
48
+ ShopifyAPI ::Base . api_version = '2019-07'
49
+ fake "products/632910392/variants/808950810" , :method => :get , :body => load_fixture ( 'variant' )
50
+ variant = ShopifyAPI ::Variant . find ( 808950810 , :params => { :product_id => 632910392 } )
51
+ assert variant . as_json . include? ( 'inventory_quantity' )
52
+ end
53
+
54
+ def test_deprecated_inventory_fields_are_removed_in_2020_01
55
+ ShopifyAPI ::Base . api_version = '2020-01'
56
+ fake "products/632910392/variants/808950810" , :method => :get , :body => load_fixture ( 'variant' )
57
+ variant = ShopifyAPI ::Variant . find ( 808950810 , :params => { :product_id => 632910392 } )
58
+ refute variant . as_json . include? ( 'inventory_quantity' )
59
+ end
60
+
47
61
def test_setting_variant_inventory_quantity_adjustment_passes_in_api_before_2019_10
48
62
ShopifyAPI ::Base . api_version = '2019-07'
49
63
fake "products/632910392/variants/808950810" , :method => :get , :body => load_fixture ( 'variant' )
You can’t perform that action at this time.
0 commit comments