Преглед на файлове

Add tests for deleting common objects

Hammad Khalid преди 10 години
родител
ревизия
dc3a0a64ac
променени са 3 файла, в които са добавени 28 реда и са изтрити 0 реда
  1. 14 0
      test/image_test.rb
  2. 7 0
      test/order_test.rb
  3. 7 0
      test/variant_test.rb

+ 14 - 0
test/image_test.rb

@@ -1,6 +1,7 @@
 require 'test_helper'
 
 class ImageTest < Test::Unit::TestCase
+
   def test_create_image
     fake "products/632910392/images", :method => :post, :body => load_fixture('image')
     image = ShopifyAPI::Image.new(:product_id => 632910392)
@@ -23,4 +24,17 @@ class ImageTest < Test::Unit::TestCase
     image = ShopifyAPI::Image.find(850703190, :params => {:product_id => 632910392})
     assert_equal 850703190, image.id
   end
+
+  def test_delete_image
+    fake "products/632910392/images/850703190", :method => :get, :body => load_fixture('image')
+    fake "products/632910392/images/850703190", :method => :delete, :body => "destroyed"
+    image = ShopifyAPI::Image.find(850703190, :params => {:product_id => 632910392})
+    assert image.destroy
+  end
+
+  def test_delete_image_without_fetching
+    fake "products/632910392/images/850703190", :method => :delete, :body => "destroyed"
+    image = ShopifyAPI::Image.new(product_id: 632910392, id: 850703190)
+    assert image.destroy
+  end
 end

+ 7 - 0
test/order_test.rb

@@ -28,5 +28,12 @@ class OrderTest < Test::Unit::TestCase
     order.save
     assert_equal "Test note", order.note
   end
+
+  test "delete should delete an order" do
+    fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
+    fake 'orders/450789469', :method => :delete, :body => 'destroyed'
+    order = ShopifyAPI::Order.find(450789469)
+    assert order.destroy
+  end
 end
 

+ 7 - 0
test/variant_test.rb

@@ -33,4 +33,11 @@ class VariantTest < Test::Unit::TestCase
     v = ShopifyAPI::Variant.find(808950810)
     assert_equal 632910392, v.product_id
   end
+
+  def test_delete_variant
+    fake "products/632910392/variants/808950810", :method => :get, :body => load_fixture('variant')
+    fake "products/632910392/variants/808950810", :method => :delete, :body => 'destroyed'
+    v = ShopifyAPI::Variant.find(808950810, :params => {:product_id => 632910392})
+    assert v.destroy
+  end
 end