Ver Fonte

Merge pull request #255 from Shopify/adds-ability-to-open-fulfillment

Adds ability to open a fulfillment.
Gareth du Plooy há 9 anos atrás
pai
commit
679cda9cdc
2 ficheiros alterados com 15 adições e 0 exclusões
  1. 1 0
      lib/shopify_api/resources/fulfillment.rb
  2. 14 0
      test/fulfillment_test.rb

+ 1 - 0
lib/shopify_api/resources/fulfillment.rb

@@ -8,5 +8,6 @@ module ShopifyAPI
 
     def cancel; load_attributes_from_response(post(:cancel, {}, only_id)); end
     def complete; load_attributes_from_response(post(:complete, {}, only_id)); end
+    def open; load_attributes_from_response(post(:open, {}, only_id)); end
   end
 end

+ 14 - 0
test/fulfillment_test.rb

@@ -34,6 +34,20 @@ class FulFillmentTest < Test::Unit::TestCase
       end
     end
 
+    context "#open" do
+      should "be able to open a fulfillment" do
+        fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
+
+        open_fulfillment = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
+        open_fulfillment['fulfillment']['status'] = 'open'
+        fake "orders/450789469/fulfillments/255858046/open", :method => :post, :body => ActiveSupport::JSON.encode(open_fulfillment)
+
+        assert_equal 'pending', fulfillment.status
+        assert fulfillment.open
+        assert_equal 'open', fulfillment.status
+      end
+    end
+
     context "#find" do
       should "be able to find fulfillment" do
         fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})