Browse Source

code style adjustments

Jon Grenning 7 years ago
parent
commit
f05c460d73

+ 1 - 2
lib/shopify_api/resources/inventory_level.rb

@@ -17,8 +17,7 @@ module ShopifyAPI
 
     def destroy
       load_attributes_from_response(
-        self.class.delete('/', location_id: location_id,
-                               inventory_item_id: inventory_item_id)
+        self.class.delete('/', location_id: location_id, inventory_item_id: inventory_item_id)
       )
     end
 

+ 1 - 1
lib/shopify_api/resources/location.rb

@@ -2,7 +2,7 @@ module ShopifyAPI
   class Location < Base
 
     def inventory_levels
-      ShopifyAPI::InventoryLevel.find :all, from: "/admin/locations/#{id}/inventory_levels.json"
+      ShopifyAPI::InventoryLevel.find(:all, from: "/admin/locations/#{id}/inventory_levels.json")
     end
   end
 end

+ 1 - 1
test/fixtures/inventory_level.json

@@ -4,4 +4,4 @@
       "location_id": 905684977,
       "available": 1
   }
-}
+}

+ 1 - 1
test/fixtures/inventory_levels.json

@@ -21,4 +21,4 @@
       "available": 3
     }
   ]
-}
+}

+ 5 - 5
test/inventory_level_test.rb

@@ -7,7 +7,7 @@ class InventoryLevelTest < Test::Unit::TestCase
     @inventory_level = ShopifyAPI::InventoryLevel.new(@inventory_level_response['inventory_level'])
   end
 
-  test 'Retrieve inventory levels for the specified inventory_items and locations' do
+  test ".find with inventory_item_ids and location_ids returns expected inventory levels" do
     params = { inventory_item_ids: [808950810, 39072856], location_ids: [905684977, 487838322] }
     fake "inventory_levels.json?#{params.to_param}", extension: false, method: :get,
           status: 200, body: load_fixture('inventory_levels')
@@ -19,7 +19,7 @@ class InventoryLevelTest < Test::Unit::TestCase
     }, message: 'Response contained inventory_items or locations not requested.'
   end
 
-  test 'Adjust an inventory level by 5' do
+  test '#adjust with adjustment value returns inventory_level with available increased by adjustment value' do
     adjustment = 5
     updated_available = @inventory_level.available + adjustment
     @inventory_level_response[:available] = updated_available
@@ -29,7 +29,7 @@ class InventoryLevelTest < Test::Unit::TestCase
     assert_equal updated_available, @inventory_level.available
   end
 
-  test 'Connect an inventory_item to a location' do
+  test '#connect saves an inventory_level associated with inventory_item and location_id' do
     params = { inventory_item_id: 808950810, location_id: 99999999 }
     response = params.clone
     response[:available] = 0
@@ -40,13 +40,13 @@ class InventoryLevelTest < Test::Unit::TestCase
     assert_equal 0, inventory_level.available, message: 'expected newly connected location to have 0 inventory'
   end
 
-  test 'Destroy an inventory_level' do
+  test '#destroy removes inventory_level and returns nil' do
     params = { inventory_item_id: @inventory_level.inventory_item_id, location_id: @inventory_level.location_id }
     fake "inventory_levels.json?#{params.to_param}", extension: false, method: :delete, status: 204, body: nil
     assert_nil @inventory_level.destroy
   end
 
-  test 'Set the available inventory for an inventory_level' do
+  test '#set with available value returns inventory_level with available as the available value' do
     available = 13
     response = @inventory_level_response.clone
     response['inventory_level']['available'] = available

+ 1 - 1
test/location_test.rb

@@ -1,7 +1,7 @@
 require 'test_helper'
 
 class LocationTest < Test::Unit::TestCase
-  test 'Retrieve inventory levels for the specified inventory_items and locations' do
+  test '#inventory_levels returns all inventory_levels associated with this location' do
     location = ShopifyAPI::Location.new(id: 487838322)
     expected_body = JSON.parse(load_fixture('inventory_levels'))
     expected_body['inventory_levels'].delete_if {|level| level['location_id'] != location.id }