Skip to content

Commit 82843fa

Browse files
committed
tests
1 parent 0ed662d commit 82843fa

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

lib/shopify_api/resources/product.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def total_inventory=(new_value)
2222
end
2323

2424
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')
2626
end
2727

2828
def collections

lib/shopify_api/resources/variant.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def old_inventory_quantity=(new_value)
2121
end
2222

2323
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')
2525
end
2626

2727
private

test/product_test.rb

+17
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ def test_price_range_when_has_different_price
5858
assert_equal('100.00 - 199.00', @product.price_range)
5959
end
6060

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+
6178
def test_setting_product_total_inventory_passes_in_api_before_2019_10
6279
ShopifyAPI::Base.api_version = '2019-07'
6380
fake("products/632910392", {:body => load_fixture('product')})

test/variant_test.rb

+14
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ def test_delete_variant
4444
assert v.destroy
4545
end
4646

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+
4761
def test_setting_variant_inventory_quantity_adjustment_passes_in_api_before_2019_10
4862
ShopifyAPI::Base.api_version = '2019-07'
4963
fake "products/632910392/variants/808950810", :method => :get, :body => load_fixture('variant')

0 commit comments

Comments
 (0)