collection_test.rb 921 B

1234567891011121314151617181920212223242526272829
  1. require 'test_helper'
  2. class CollectionTest < Test::Unit::TestCase
  3. test "Collection get products gets all products in a collection" do
  4. unstable_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: :unstable)
  5. ShopifyAPI::Base.activate_session(unstable_version)
  6. fake(
  7. 'collections',
  8. url: 'https://shop2.myshopify.com/admin/api/unstable/collections/1.json',
  9. method: :get,
  10. status: 200,
  11. body: load_fixture('collection'),
  12. extension: false
  13. )
  14. collection = ShopifyAPI::Collection.find(1)
  15. fake(
  16. 'products',
  17. url: 'https://shop2.myshopify.com/admin/api/unstable/collections/1/products.json',
  18. method: :get,
  19. status: 200,
  20. body: load_fixture('collection_products'),
  21. extension: false
  22. )
  23. assert_equal [632910392, 921728736], collection.products.map(&:id)
  24. end
  25. end