Skip to content

Commit

Permalink
Release 2020-01 Collections#products
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacio-chiazzo committed Dec 23, 2019
1 parent 2a930d0 commit 0c37b3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/shopify_api/resources/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Collection < Base
include Metafields

def products(options = {})
available_in_version = ShopifyAPI::ApiVersion.find_version(:unstable)
available_in_version = ShopifyAPI::ApiVersion.find_version('2020-01')
raise NotImplementedError unless ShopifyAPI::Base.api_version >= available_in_version
Product.find(:all, from: "#{self.class.prefix}collections/#{id}/products.json", params: options)
end
Expand Down
16 changes: 8 additions & 8 deletions test/collection_test.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'test_helper'

class CollectionTest < Test::Unit::TestCase
test "Collection get products gets all products in a collection on unstable version" do
unstable_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: :unstable)
ShopifyAPI::Base.activate_session(unstable_version)
test "Collection get products gets all products in a collection on 2020-01 version" do
available_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: '2020-01')
ShopifyAPI::Base.activate_session(available_version)

fake(
'collections',
url: 'https://shop2.myshopify.com/admin/api/unstable/collections/1.json',
url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1.json',
method: :get,
status: 200,
body: load_fixture('collection'),
Expand All @@ -18,7 +18,7 @@ class CollectionTest < Test::Unit::TestCase

fake(
'products',
url: 'https://shop2.myshopify.com/admin/api/unstable/collections/1/products.json',
url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1/products.json',
method: :get,
status: 200,
body: load_fixture('collection_products'),
Expand All @@ -28,12 +28,12 @@ class CollectionTest < Test::Unit::TestCase
end

test "Collection get products fails on older api version" do
unstable_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: '2019-07')
ShopifyAPI::Base.activate_session(unstable_version)
old_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: '2019-10')
ShopifyAPI::Base.activate_session(old_version)

fake(
'collections',
url: 'https://shop2.myshopify.com/admin/api/2019-07/collections/1.json',
url: 'https://shop2.myshopify.com/admin/api/2019-10/collections/1.json',
method: :get,
status: 200,
body: load_fixture('collection'),
Expand Down

0 comments on commit 0c37b3c

Please sign in to comment.