|
@@ -57,4 +57,43 @@ class ProductTest < Test::Unit::TestCase
|
|
|
|
|
|
assert_equal('100.00 - 199.00', @product.price_range)
|
|
|
end
|
|
|
+
|
|
|
+ def test_deprecated_variant_inventory_fields_are_included_in_2019_07
|
|
|
+ ShopifyAPI::Base.api_version = '2019-07'
|
|
|
+ variant = @product.variants.first
|
|
|
+ assert variant.as_json.include?('inventory_quantity')
|
|
|
+ end
|
|
|
+
|
|
|
+ def test_deprecated_variant_inventory_fields_are_removed_in_2020_01
|
|
|
+ ShopifyAPI::Base.api_version = '2020-01'
|
|
|
+ variant = @product.variants.first
|
|
|
+ refute variant.as_json.include?('inventory_quantity')
|
|
|
+ end
|
|
|
+
|
|
|
+ def test_deprecated_inventory_fields_are_removed_in_2020_01
|
|
|
+ ShopifyAPI::Base.api_version = '2020-01'
|
|
|
+ refute @product.as_json.include?('total_inventory')
|
|
|
+ end
|
|
|
+
|
|
|
+ def test_setting_product_total_inventory_passes_in_api_before_2019_10
|
|
|
+ ShopifyAPI::Base.api_version = '2019-07'
|
|
|
+ fake("products/632910392", {:body => load_fixture('product')})
|
|
|
+ @product.total_inventory = 8
|
|
|
+ end
|
|
|
+
|
|
|
+ def test_setting_product_total_inventory_fails_in_2019_10_api
|
|
|
+ ShopifyAPI::Base.api_version = '2019-10'
|
|
|
+ fake("products/632910392", {:body => load_fixture('product')})
|
|
|
+ assert_raises(ShopifyAPI::ValidationException) do
|
|
|
+ @product.total_inventory = 8
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ def test_setting_product_total_inventory_fails_in_the_unstable_api
|
|
|
+ ShopifyAPI::Base.api_version = :unstable
|
|
|
+ fake("products/632910392", {:body => load_fixture('product')})
|
|
|
+ assert_raises(ShopifyAPI::ValidationException) do
|
|
|
+ @product.total_inventory = 8
|
|
|
+ end
|
|
|
+ end
|
|
|
end
|