shopify_api 7.0.2 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +1027 -0
  3. data/CHANGELOG.md +7 -0
  4. data/README.md +30 -0
  5. data/Rakefile +1 -1
  6. data/lib/shopify_api.rb +2 -1
  7. data/lib/shopify_api/api_version.rb +17 -0
  8. data/lib/shopify_api/defined_versions.rb +1 -0
  9. data/lib/shopify_api/paginated_collection.rb +57 -0
  10. data/lib/shopify_api/pagination_link_headers.rb +33 -0
  11. data/lib/shopify_api/resources.rb +2 -1
  12. data/lib/shopify_api/resources/array_base.rb +13 -0
  13. data/lib/shopify_api/resources/base.rb +24 -21
  14. data/lib/shopify_api/resources/collect.rb +1 -0
  15. data/lib/shopify_api/resources/collection_listing.rb +10 -1
  16. data/lib/shopify_api/resources/customer_saved_search.rb +2 -0
  17. data/lib/shopify_api/resources/event.rb +1 -0
  18. data/lib/shopify_api/resources/metafield.rb +1 -0
  19. data/lib/shopify_api/resources/product.rb +2 -0
  20. data/lib/shopify_api/resources/product_listing.rb +8 -1
  21. data/lib/shopify_api/version.rb +1 -1
  22. data/shopify_api.gemspec +1 -1
  23. data/test/api_version_test.rb +14 -0
  24. data/test/base_test.rb +12 -6
  25. data/test/blog_test.rb +1 -1
  26. data/test/collection_listing_test.rb +38 -0
  27. data/test/collection_publication_test.rb +1 -1
  28. data/test/customer_test.rb +2 -2
  29. data/test/discount_code_test.rb +2 -2
  30. data/test/draft_order_test.rb +4 -4
  31. data/test/fixtures/collection_listing_product_ids2.json +1 -0
  32. data/test/fixtures/product_listing_product_ids.json +1 -1
  33. data/test/fixtures/product_listing_product_ids2.json +1 -0
  34. data/test/lib/webmock_extensions/last_request.rb +16 -0
  35. data/test/metafield_test.rb +1 -1
  36. data/test/pagination_test.rb +229 -0
  37. data/test/price_rule_test.rb +1 -1
  38. data/test/product_listing_test.rb +59 -2
  39. data/test/product_publication_test.rb +1 -1
  40. data/test/product_test.rb +1 -1
  41. data/test/recurring_application_charge_test.rb +3 -4
  42. data/test/shop_test.rb +1 -1
  43. data/test/tax_service_test.rb +2 -1
  44. data/test/test_helper.rb +83 -83
  45. metadata +12 -5
@@ -3,6 +3,6 @@ class BlogTest < Test::Unit::TestCase
3
3
  test "blog creation" do
4
4
  fake "blogs", :method => :post, :status => 202, :body => load_fixture('blog')
5
5
  blog = ShopifyAPI::Blog.create(:title => "Test Blog")
6
- assert_equal '{"blog":{"title":"Test Blog"}}', FakeWeb.last_request.body
6
+ assert_equal '{"blog":{"title":"Test Blog"}}', WebMock.last_request.body
7
7
  end
8
8
  end
@@ -38,4 +38,42 @@ class CollectionListingTest < Test::Unit::TestCase
38
38
 
39
39
  assert_equal [1, 2], collection_listing.product_ids
40
40
  end
41
+
42
+ def test_get_collection_listing_product_ids_multi_page_with_cursor
43
+ version = ShopifyAPI::ApiVersion::Release.new('2019-07')
44
+ ShopifyAPI::Base.api_version = version.to_s
45
+
46
+ collection_listing = ShopifyAPI::CollectionListing.new(collection_id: 1)
47
+
48
+ url = "https://this-is-my-test-shop.myshopify.com/admin/api/2019-07/collection_listings/1/product_ids.json"
49
+
50
+ next_page_info = "notarealpageinfobutthatsokay"
51
+ next_page_url = "#{url}?page_info=#{next_page_info}"
52
+ link_header = "<#{next_page_url}>; rel=\"next\""
53
+
54
+ fake(
55
+ "collection_listings/1/product_ids",
56
+ method: :get,
57
+ status: 201,
58
+ url: url,
59
+ body: load_fixture('collection_listing_product_ids'),
60
+ link: link_header,
61
+ )
62
+
63
+ product_ids = collection_listing.product_ids
64
+ assert_equal [1, 2], product_ids
65
+ assert product_ids.next_page?
66
+
67
+ fake(
68
+ "collection_listings/1/product_ids",
69
+ method: :get,
70
+ status: 201,
71
+ url: next_page_url,
72
+ body: load_fixture('collection_listing_product_ids2'),
73
+ link: link_header,
74
+ )
75
+
76
+ next_page = product_ids.fetch_next_page
77
+ assert_equal [3, 4], next_page
78
+ end
41
79
  end
@@ -35,6 +35,6 @@ class CollectionPublicationTest < Test::Unit::TestCase
35
35
  },
36
36
  }.to_json
37
37
 
38
- assert_equal expected_body, FakeWeb.last_request.body
38
+ assert_equal expected_body, WebMock.last_request.body
39
39
  end
40
40
  end
@@ -30,7 +30,7 @@ class CustomerTest < Test::Unit::TestCase
30
30
 
31
31
  customer_invite_response = @customer.send_invite
32
32
 
33
- assert_equal '{"customer_invite":{}}', FakeWeb.last_request.body
33
+ assert_equal '{"customer_invite":{}}', WebMock.last_request.body
34
34
  assert_kind_of ShopifyAPI::CustomerInvite, customer_invite_response
35
35
  assert_equal customer_invite['customer_invite']['to'], customer_invite_response.to
36
36
  end
@@ -43,7 +43,7 @@ class CustomerTest < Test::Unit::TestCase
43
43
 
44
44
  customer_invite_response = @customer.send_invite(ShopifyAPI::CustomerInvite.new(customer_invite['customer_invite']))
45
45
 
46
- assert_equal customer_invite, ActiveSupport::JSON.decode(FakeWeb.last_request.body)
46
+ assert_equal customer_invite, ActiveSupport::JSON.decode(WebMock.last_request.body)
47
47
  assert_kind_of ShopifyAPI::CustomerInvite, customer_invite_response
48
48
  assert_equal customer_invite['customer_invite']['to'], customer_invite_response.to
49
49
  end
@@ -30,7 +30,7 @@ class DiscountCodeTest < Test::Unit::TestCase
30
30
  discount_code.code = "SUMMERSALE10"
31
31
  discount_code.save
32
32
 
33
- assert_equal '{"discount_code":{"code":"SUMMERSALE10"}}', FakeWeb.last_request.body
33
+ assert_equal '{"discount_code":{"code":"SUMMERSALE10"}}', WebMock.last_request.body
34
34
  end
35
35
 
36
36
  def test_update_discount_code
@@ -41,7 +41,7 @@ class DiscountCodeTest < Test::Unit::TestCase
41
41
  fake 'price_rules/102586120/discount_codes/1002091923', method: :put, status: 200, body: ActiveSupport::JSON.encode(discount_code_response)
42
42
 
43
43
  @discount_code.save
44
-
44
+
45
45
  assert_equal discount_code_response['discount_code']['code'], @discount_code.code
46
46
  end
47
47
 
@@ -39,7 +39,7 @@ class DraftOrderTest < Test::Unit::TestCase
39
39
 
40
40
  draft_order = ShopifyAPI::DraftOrder.create(line_items: [{ quantity: 1, variant_id: 39072856 }])
41
41
 
42
- assert_equal '{"draft_order":{"line_items":[{"quantity":1,"variant_id":39072856}]}}', FakeWeb.last_request.body
42
+ assert_equal '{"draft_order":{"line_items":[{"quantity":1,"variant_id":39072856}]}}', WebMock.last_request.body
43
43
  assert_equal 39072856, draft_order.line_items.first.variant_id
44
44
  end
45
45
 
@@ -69,7 +69,7 @@ class DraftOrderTest < Test::Unit::TestCase
69
69
 
70
70
  draft_order_invoice_response = @draft_order.send_invoice
71
71
 
72
- assert_equal '{"draft_order_invoice":{}}', FakeWeb.last_request.body
72
+ assert_equal '{"draft_order_invoice":{}}', WebMock.last_request.body
73
73
  assert_kind_of ShopifyAPI::DraftOrderInvoice, draft_order_invoice_response
74
74
  assert_equal draft_order_invoice['draft_order_invoice']['to'], draft_order_invoice_response.to
75
75
  end
@@ -81,7 +81,7 @@ class DraftOrderTest < Test::Unit::TestCase
81
81
 
82
82
  draft_order_invoice_response = @draft_order.send_invoice(ShopifyAPI::DraftOrderInvoice.new(draft_order_invoice['draft_order_invoice']))
83
83
 
84
- assert_equal draft_order_invoice, ActiveSupport::JSON.decode(FakeWeb.last_request.body)
84
+ assert_equal draft_order_invoice, ActiveSupport::JSON.decode(WebMock.last_request.body)
85
85
  assert_kind_of ShopifyAPI::DraftOrderInvoice, draft_order_invoice_response
86
86
  assert_equal draft_order_invoice['draft_order_invoice']['to'], draft_order_invoice_response.to
87
87
  end
@@ -96,7 +96,7 @@ class DraftOrderTest < Test::Unit::TestCase
96
96
 
97
97
  field = @draft_order.add_metafield(ShopifyAPI::Metafield.new(namespace: 'contact', key: 'email', value: '123@example.com', value_type: 'string'))
98
98
 
99
- assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"contact","key":"email","value":"123@example.com","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
99
+ assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"contact","key":"email","value":"123@example.com","value_type":"string"}}'), ActiveSupport::JSON.decode(WebMock.last_request.body)
100
100
  assert !field.new_record?
101
101
  assert_equal 'contact', field.namespace
102
102
  assert_equal 'email', field.key
@@ -1 +1 @@
1
- [2, 1]
1
+ [4, 3]
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LastRequest
4
+ def last_request
5
+ @last_request
6
+ end
7
+
8
+ def last_request=(request_signature)
9
+ @last_request = request_signature
10
+ end
11
+ end
12
+
13
+ WebMock.extend(LastRequest)
14
+ WebMock.after_request do |request_signature, response|
15
+ WebMock.last_request = request_signature
16
+ end
@@ -24,7 +24,7 @@ class MetafieldTest < Test::Unit::TestCase
24
24
  blog = ShopifyAPI::Blog.find(1008414260)
25
25
  metafield = blog.add_metafield(ShopifyAPI::Metafield.new(:namespace => "summaries", :key => "First Summary", :value => "Make commerce better", :value_type => "string"))
26
26
 
27
- assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"summaries","key":"First Summary","value":"Make commerce better","value_type":"string"}}'), ActiveSupport::JSON.decode(FakeWeb.last_request.body)
27
+ assert_equal ActiveSupport::JSON.decode('{"metafield":{"namespace":"summaries","key":"First Summary","value":"Make commerce better","value_type":"string"}}'), ActiveSupport::JSON.decode(WebMock.last_request.body)
28
28
  assert !metafield.new_record?
29
29
  end
30
30
 
@@ -0,0 +1,229 @@
1
+ require 'test_helper'
2
+
3
+ class PaginationTest < Test::Unit::TestCase
4
+ def setup
5
+ super
6
+
7
+ @version = ShopifyAPI::ApiVersion::Release.new('2019-10')
8
+ ShopifyAPI::Base.api_version = @version.to_s
9
+ @next_page_info = "eyJkaXJlY3Rpb24iOiJuZXh0IiwibGFzdF9pZCI6NDQwMDg5NDIzLCJsYXN0X3ZhbHVlIjoiNDQwMDg5NDIzIn0%3D"
10
+ @previous_page_info = "eyJsYXN0X2lkIjoxMDg4MjgzMDksImxhc3RfdmFsdWUiOiIxMDg4MjgzMDkiLCJkaXJlY3Rpb24iOiJuZXh0In0%3D"
11
+
12
+ @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@next_page_info}>; rel=\"next\""
13
+ @previous_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@previous_page_info}>; rel=\"previous\""
14
+ end
15
+
16
+ test "navigates using next and previous link headers with no original params" do
17
+ link_header ="#{@previous_link_header}, #{@next_link_header}"
18
+
19
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => link_header
20
+ orders = ShopifyAPI::Order.all
21
+
22
+ fake(
23
+ 'orders',
24
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@next_page_info}",
25
+ method: :get,
26
+ status: 200,
27
+ body: load_fixture('orders')
28
+ )
29
+ next_page = orders.fetch_next_page
30
+ assert_equal 450789469, next_page.first.id
31
+
32
+ fake(
33
+ 'orders',
34
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@previous_page_info}",
35
+ method: :get,
36
+ status: 200,
37
+ body: load_fixture('orders').gsub("450789469", "1122334455")
38
+ )
39
+
40
+ previous_page = orders.fetch_previous_page
41
+ assert_equal 1122334455, previous_page.first.id
42
+ end
43
+
44
+ test "uses all passed in querystring parameters" do
45
+ params = "page_info=#{@next_page_info}&limit=50&fields=#{CGI.escape('id,created_at')}"
46
+ @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?#{params}>; rel=\"next\""
47
+ fake(
48
+ 'orders',
49
+ method: :get,
50
+ status: 200,
51
+ api_version: @version,
52
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?fields=id%2Cupdated_at&limit=100",
53
+ body: load_fixture('orders'),
54
+ link: @next_link_header
55
+ )
56
+ orders = ShopifyAPI::Order.where(fields: 'id,updated_at', limit: 100)
57
+
58
+ fake(
59
+ 'orders',
60
+ method: :get,
61
+ status: 200,
62
+ api_version: @version,
63
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?fields=id%2Ccreated_at&limit=50&page_info=#{@next_page_info}",
64
+ body: load_fixture('orders')
65
+ )
66
+ next_page = orders.fetch_next_page
67
+ assert_equal 450789469, next_page.first.id
68
+ end
69
+
70
+ test "returns empty next page if just the previous page is present" do
71
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
72
+ orders = ShopifyAPI::Order.all
73
+
74
+ next_page = orders.fetch_next_page
75
+ assert_empty next_page
76
+ end
77
+
78
+ test "returns an empty previous page if just the next page is present" do
79
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
80
+ orders = ShopifyAPI::Order.all
81
+
82
+ next_page = orders.fetch_previous_page
83
+ assert_empty next_page
84
+ end
85
+
86
+ test "#next_page? returns true if next page is present" do
87
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
88
+ orders = ShopifyAPI::Order.all
89
+
90
+ assert orders.next_page?
91
+ end
92
+
93
+ test "#next_page? returns false if next page is not present" do
94
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
95
+ orders = ShopifyAPI::Order.all
96
+
97
+ refute orders.next_page?
98
+ end
99
+
100
+ test "#previous_page? returns true if previous page is present" do
101
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
102
+ orders = ShopifyAPI::Order.all
103
+
104
+ assert orders.previous_page?
105
+ end
106
+
107
+ test "#previous_page? returns false if next page is not present" do
108
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
109
+ orders = ShopifyAPI::Order.all
110
+
111
+ refute orders.previous_page?
112
+ end
113
+
114
+ test "pagination handles no link headers" do
115
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders')
116
+ orders = ShopifyAPI::Order.all
117
+
118
+ refute orders.next_page?
119
+ refute orders.previous_page?
120
+ assert_empty orders.fetch_next_page
121
+ assert_empty orders.fetch_previous_page
122
+ end
123
+
124
+ test "raises on invalid pagination links" do
125
+ link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@next_page_info}>;"
126
+ fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => link_header
127
+
128
+ assert_raises ShopifyAPI::InvalidPaginationLinksError do
129
+ ShopifyAPI::Order.all
130
+ end
131
+ end
132
+
133
+ test "raises on an older API version" do
134
+ version = ShopifyAPI::ApiVersion::Release.new('2019-04')
135
+ ShopifyAPI::Base.api_version = version.to_s
136
+
137
+ fake 'orders', :method => :get, :status => 200, api_version: version, :body => load_fixture('orders')
138
+ orders = ShopifyAPI::Order.all
139
+
140
+ assert_raises NotImplementedError do
141
+ orders.fetch_next_page
142
+ end
143
+ end
144
+
145
+ test "raises on 2019-07 API version for models that don't support new pagination yet" do
146
+ version = ShopifyAPI::ApiVersion::Release.new('2019-07')
147
+ ShopifyAPI::Base.api_version = version.to_s
148
+
149
+ fake 'orders', :method => :get, :status => 200, api_version: version, :body => load_fixture('orders')
150
+ orders = ShopifyAPI::Order.all
151
+
152
+ assert_raises NotImplementedError do
153
+ orders.fetch_next_page
154
+ end
155
+ end
156
+
157
+ test "new pagination works on 2019-07 API version for select models" do
158
+ version = ShopifyAPI::ApiVersion::Release.new('2019-07')
159
+ ShopifyAPI::Base.api_version = version.to_s
160
+
161
+ fake 'events', :method => :get, :status => 200, api_version: version, :body => load_fixture('events')
162
+ events = ShopifyAPI::Event.all
163
+
164
+ assert_empty events.fetch_next_page
165
+ assert_empty events.fetch_previous_page
166
+ end
167
+
168
+ test "does not raise on the unstable version" do
169
+ version = ShopifyAPI::ApiVersion::Unstable.new
170
+ ShopifyAPI::Base.api_version = version.to_s
171
+ @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/unstable/orders.json?page_info=#{@next_page_info}>; rel=\"next\""
172
+
173
+ link_header ="#{@previous_link_header}, #{@next_link_header}"
174
+
175
+ fake 'orders', :method => :get, :status => 200, api_version: version, :body => load_fixture('orders'), :link => link_header
176
+ orders = ShopifyAPI::Order.all
177
+
178
+ fake(
179
+ 'orders',
180
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/unstable/orders.json?page_info=#{@next_page_info}",
181
+ method: :get,
182
+ status: 200,
183
+ body: load_fixture('orders')
184
+ )
185
+ assert_nothing_raised do
186
+ next_page = orders.fetch_next_page
187
+ assert_equal 450789469, next_page.first.id
188
+ end
189
+ end
190
+
191
+ test "allows for multiple concurrent API collection objects" do
192
+ first_request_params = "page_info=#{@next_page_info}&limit=5"
193
+ fake(
194
+ 'orders',
195
+ method: :get,
196
+ status: 200,
197
+ api_version: @version,
198
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?limit=5",
199
+ body: load_fixture('orders'),
200
+ link: "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?#{first_request_params}>; rel=\"next\""
201
+ )
202
+ orders = ShopifyAPI::Order.where(limit: 5)
203
+
204
+ second_request_params = "page_info=#{@next_page_info}&limit=5"
205
+ fake(
206
+ 'orders',
207
+ method: :get,
208
+ status: 200,
209
+ api_version: @version,
210
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?limit=10",
211
+ body: load_fixture('orders'),
212
+ link: "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?#{second_request_params}>; rel=\"next\""
213
+ )
214
+
215
+ orders2 = ShopifyAPI::Order.where(limit: 10)
216
+
217
+ fake(
218
+ 'orders',
219
+ method: :get,
220
+ status: 200,
221
+ api_version: @version,
222
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?limit=5&page_info=#{@next_page_info}",
223
+ body: load_fixture('orders')
224
+ )
225
+ next_page = orders.fetch_next_page
226
+ assert_equal 450789469, next_page.first.id
227
+ end
228
+
229
+ end
@@ -42,7 +42,7 @@ class PriceRuleTest < Test::Unit::TestCase
42
42
  starts_at: "2017-01-19T00:00:00Z"
43
43
  )
44
44
 
45
- assert_equal '{"price_rule":{"target_type":"line_item","allocation_method":"across","value_type":"fixed_amount","value":-10.0,"customer_selection":"all","starts_at":"2017-01-19T00:00:00Z"}}', FakeWeb.last_request.body
45
+ assert_equal '{"price_rule":{"target_type":"line_item","allocation_method":"across","value_type":"fixed_amount","value":-10.0,"customer_selection":"all","starts_at":"2017-01-19T00:00:00Z"}}', WebMock.last_request.body
46
46
  assert_equal -10, price_rule.value
47
47
  end
48
48
 
@@ -34,7 +34,64 @@ class ProductListingTest < Test::Unit::TestCase
34
34
 
35
35
  product_ids = ShopifyAPI::ProductListing.product_ids
36
36
  assert_equal 2, product_ids.count
37
- assert_equal 2, product_ids.first
38
- assert_equal 1, product_ids.last
37
+ assert_equal 4, product_ids.first
38
+ assert_equal 3, product_ids.last
39
+ end
40
+
41
+ def test_get_product_listing_product_ids_multi_page_with_cursor
42
+ version = ShopifyAPI::ApiVersion::Release.new('2019-10')
43
+ ShopifyAPI::Base.api_version = version.to_s
44
+
45
+ url = "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/product_listings/product_ids.json"
46
+
47
+ next_page_info = "notarealpageinfobutthatsokay"
48
+ next_page_url = "#{url}?page_info=#{next_page_info}"
49
+ link_header = "<#{next_page_url}>; rel=\"next\""
50
+
51
+ fake(
52
+ "product_listings/product_ids",
53
+ method: :get,
54
+ status: 201,
55
+ url: url,
56
+ body: load_fixture('product_listing_product_ids'),
57
+ link: link_header,
58
+ )
59
+
60
+ product_ids = ShopifyAPI::ProductListing.product_ids
61
+ assert_equal [4, 3], product_ids
62
+ assert product_ids.next_page?
63
+
64
+ fake(
65
+ "product_listings/product_ids",
66
+ method: :get,
67
+ status: 201,
68
+ url: next_page_url,
69
+ body: load_fixture('product_listing_product_ids2'),
70
+ link: link_header,
71
+ )
72
+
73
+ next_page = product_ids.fetch_next_page
74
+ assert_equal [2, 1], next_page
75
+ end
76
+
77
+ def test_get_product_listing_product_ids_multi_page_with_cursor_fails_on_older_api_version
78
+ version = ShopifyAPI::ApiVersion::Release.new('2019-07')
79
+ ShopifyAPI::Base.api_version = version.to_s
80
+
81
+ url = "https://this-is-my-test-shop.myshopify.com/admin/api/2019-07/product_listings/product_ids.json"
82
+
83
+ fake(
84
+ "product_listings/product_ids",
85
+ method: :get,
86
+ status: 201,
87
+ url: url,
88
+ body: load_fixture('product_listing_product_ids'),
89
+ )
90
+
91
+ product_ids = ShopifyAPI::ProductListing.product_ids
92
+ assert_equal [4, 3], product_ids
93
+ assert_raises NotImplementedError do
94
+ product_ids.next_page?
95
+ end
39
96
  end
40
97
  end