| 
					
				 | 
			
			
				@@ -4,8 +4,7 @@ class ProductTest < Test::Unit::TestCase 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   def setup 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     super 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    fake "products/632910392", :body => load_fixture('product') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @product = ShopifyAPI::Product.find(632910392) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   def test_add_metafields_to_product 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -60,30 +59,36 @@ class ProductTest < Test::Unit::TestCase 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   def test_deprecated_variant_inventory_fields_are_included_in_2019_07 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ShopifyAPI::Base.api_version = '2019-07' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product(api_version: ShopifyAPI::Base.api_version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     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' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product(api_version: ShopifyAPI::Base.api_version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     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' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product(api_version: ShopifyAPI::Base.api_version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     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') }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product(api_version: ShopifyAPI::Base.api_version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @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') }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product(api_version: ShopifyAPI::Base.api_version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     assert_raises(ShopifyAPI::ValidationException) do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       @product.total_inventory = 8 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     end 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -91,9 +96,16 @@ class ProductTest < Test::Unit::TestCase 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   def test_setting_product_total_inventory_fails_in_the_unstable_api 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ShopifyAPI::Base.api_version = :unstable 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    fake("products/632910392", { :body => load_fixture('product') }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    refresh_product(api_version: ShopifyAPI::Base.api_version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     assert_raises(ShopifyAPI::ValidationException) do 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       @product.total_inventory = 8 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  private 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def refresh_product(api_version: nil) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fake "products/632910392", :body => load_fixture('product'), api_version: api_version 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @product = ShopifyAPI::Product.find(632910392) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  end 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 end 
			 |