location_test.rb 733 B

123456789101112131415
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class LocationTest < Test::Unit::TestCase
  4. test '#inventory_levels returns all inventory_levels associated with this location' do
  5. location = ShopifyAPI::Location.new(id: 487838322)
  6. expected_body = JSON.parse(load_fixture('inventory_levels'))
  7. expected_body['inventory_levels'].delete_if { |level| level['location_id'] != location.id }
  8. fake "locations/#{location.id}/inventory_levels", method: :get, status: 200, body: JSON(expected_body).to_s
  9. inventory_levels = location.inventory_levels
  10. assert inventory_levels.all? { |item| item.location_id == location.id },
  11. message: 'Response contained locations other than the current location.'
  12. end
  13. end