shopify_api 4.9.0 → 9.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. checksums.yaml +5 -5
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE.md +36 -0
  4. data/.github/probots.yml +2 -0
  5. data/.github/workflows/build.yml +41 -0
  6. data/.gitignore +5 -1
  7. data/.rubocop.yml +28 -0
  8. data/.rubocop_todo.yml +75 -0
  9. data/CHANGELOG.md +491 -0
  10. data/CONTRIBUTING.md +1 -1
  11. data/Gemfile +6 -2
  12. data/Gemfile.lock +151 -0
  13. data/Gemfile_ar41 +5 -0
  14. data/Gemfile_ar50 +5 -0
  15. data/Gemfile_ar51 +5 -0
  16. data/Gemfile_ar_master +0 -1
  17. data/README.md +492 -100
  18. data/RELEASING +10 -9
  19. data/Rakefile +21 -5
  20. data/SECURITY.md +59 -0
  21. data/docker-compose.yml +13 -0
  22. data/docs/_config.yml +1 -0
  23. data/docs/_includes/footer.html +28 -0
  24. data/docs/_includes/head.html +28 -0
  25. data/docs/_layouts/index.html +57 -0
  26. data/docs/graphql.md +241 -0
  27. data/docs/index.md +639 -0
  28. data/lib/active_resource/connection_ext.rb +1 -0
  29. data/lib/active_resource/detailed_log_subscriber.rb +43 -7
  30. data/lib/active_resource/json_errors.rb +8 -2
  31. data/lib/shopify_api.rb +16 -6
  32. data/lib/shopify_api/api_access.rb +57 -0
  33. data/lib/shopify_api/api_version.rb +206 -0
  34. data/lib/shopify_api/connection.rb +7 -4
  35. data/lib/shopify_api/countable.rb +3 -2
  36. data/lib/shopify_api/disable_prefix_check.rb +31 -0
  37. data/lib/shopify_api/events.rb +2 -1
  38. data/lib/shopify_api/graphql.rb +103 -0
  39. data/lib/shopify_api/graphql/http_client.rb +22 -0
  40. data/lib/shopify_api/graphql/railtie.rb +17 -0
  41. data/lib/shopify_api/graphql/task.rake +100 -0
  42. data/lib/shopify_api/limits.rb +9 -9
  43. data/lib/shopify_api/message_enricher.rb +25 -0
  44. data/lib/shopify_api/meta.rb +14 -0
  45. data/lib/shopify_api/metafields.rb +5 -4
  46. data/lib/shopify_api/paginated_collection.rb +69 -0
  47. data/lib/shopify_api/pagination_link_headers.rb +34 -0
  48. data/lib/shopify_api/resources.rb +3 -1
  49. data/lib/shopify_api/resources/abandoned_checkout.rb +7 -0
  50. data/lib/shopify_api/resources/access_scope.rb +10 -0
  51. data/lib/shopify_api/resources/access_token.rb +1 -0
  52. data/lib/shopify_api/resources/address.rb +1 -0
  53. data/lib/shopify_api/resources/announcement.rb +2 -1
  54. data/lib/shopify_api/resources/api_permission.rb +9 -0
  55. data/lib/shopify_api/resources/application_charge.rb +1 -0
  56. data/lib/shopify_api/resources/application_credit.rb +1 -0
  57. data/lib/shopify_api/resources/array_base.rb +13 -0
  58. data/lib/shopify_api/resources/article.rb +3 -2
  59. data/lib/shopify_api/resources/asset.rb +28 -23
  60. data/lib/shopify_api/resources/assigned_fulfillment_order.rb +16 -0
  61. data/lib/shopify_api/resources/base.rb +101 -24
  62. data/lib/shopify_api/resources/billing_address.rb +2 -1
  63. data/lib/shopify_api/resources/blog.rb +2 -1
  64. data/lib/shopify_api/resources/carrier_service.rb +1 -0
  65. data/lib/shopify_api/resources/cart.rb +2 -1
  66. data/lib/shopify_api/resources/checkout.rb +27 -1
  67. data/lib/shopify_api/resources/collect.rb +2 -0
  68. data/lib/shopify_api/resources/collection.rb +14 -0
  69. data/lib/shopify_api/resources/collection_listing.rb +11 -1
  70. data/lib/shopify_api/resources/collection_publication.rb +10 -0
  71. data/lib/shopify_api/resources/comment.rb +20 -5
  72. data/lib/shopify_api/resources/country.rb +1 -0
  73. data/lib/shopify_api/resources/currency.rb +6 -0
  74. data/lib/shopify_api/resources/custom_collection.rb +7 -6
  75. data/lib/shopify_api/resources/customer.rb +2 -1
  76. data/lib/shopify_api/resources/customer_group.rb +1 -0
  77. data/lib/shopify_api/resources/{customer_invite_message.rb → customer_invite.rb} +1 -0
  78. data/lib/shopify_api/resources/customer_saved_search.rb +4 -1
  79. data/lib/shopify_api/resources/discount_code.rb +1 -0
  80. data/lib/shopify_api/resources/discount_code_batch.rb +34 -0
  81. data/lib/shopify_api/resources/draft_order.rb +1 -0
  82. data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
  83. data/lib/shopify_api/resources/event.rb +2 -0
  84. data/lib/shopify_api/resources/fulfillment.rb +46 -3
  85. data/lib/shopify_api/resources/fulfillment_event.rb +2 -1
  86. data/lib/shopify_api/resources/fulfillment_order.rb +151 -0
  87. data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +5 -0
  88. data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
  89. data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
  90. data/lib/shopify_api/resources/fulfillment_v2.rb +21 -0
  91. data/lib/shopify_api/resources/gift_card.rb +1 -0
  92. data/lib/shopify_api/resources/image.rb +4 -3
  93. data/lib/shopify_api/resources/inventory_item.rb +6 -0
  94. data/lib/shopify_api/resources/inventory_level.rb +54 -0
  95. data/lib/shopify_api/resources/line_item.rb +10 -1
  96. data/lib/shopify_api/resources/location.rb +4 -0
  97. data/lib/shopify_api/resources/marketing_event.rb +3 -0
  98. data/lib/shopify_api/resources/metafield.rb +2 -0
  99. data/lib/shopify_api/resources/note_attribute.rb +1 -0
  100. data/lib/shopify_api/resources/option.rb +1 -0
  101. data/lib/shopify_api/resources/order.rb +25 -5
  102. data/lib/shopify_api/resources/order_risk.rb +1 -0
  103. data/lib/shopify_api/resources/page.rb +1 -0
  104. data/lib/shopify_api/resources/payment.rb +7 -0
  105. data/lib/shopify_api/resources/payment_details.rb +1 -0
  106. data/lib/shopify_api/resources/ping.rb +3 -0
  107. data/lib/shopify_api/resources/policy.rb +1 -0
  108. data/lib/shopify_api/resources/price_rule.rb +1 -1
  109. data/lib/shopify_api/resources/product.rb +33 -7
  110. data/lib/shopify_api/resources/product_listing.rb +9 -1
  111. data/lib/shopify_api/resources/product_publication.rb +10 -0
  112. data/lib/shopify_api/resources/province.rb +1 -0
  113. data/lib/shopify_api/resources/publication.rb +5 -0
  114. data/lib/shopify_api/resources/receipt.rb +1 -0
  115. data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
  116. data/lib/shopify_api/resources/redirect.rb +1 -0
  117. data/lib/shopify_api/resources/refund.rb +6 -4
  118. data/lib/shopify_api/resources/report.rb +1 -0
  119. data/lib/shopify_api/resources/resource_feedback.rb +1 -1
  120. data/lib/shopify_api/resources/rule.rb +1 -0
  121. data/lib/shopify_api/resources/script_tag.rb +1 -0
  122. data/lib/shopify_api/resources/shipping_address.rb +1 -0
  123. data/lib/shopify_api/resources/shipping_line.rb +2 -1
  124. data/lib/shopify_api/resources/shipping_rate.rb +7 -0
  125. data/lib/shopify_api/resources/shipping_zone.rb +1 -0
  126. data/lib/shopify_api/resources/shop.rb +10 -7
  127. data/lib/shopify_api/resources/smart_collection.rb +3 -3
  128. data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
  129. data/lib/shopify_api/resources/tax_line.rb +1 -0
  130. data/lib/shopify_api/resources/tax_service.rb +1 -0
  131. data/lib/shopify_api/resources/tender_transaction.rb +6 -0
  132. data/lib/shopify_api/resources/theme.rb +1 -0
  133. data/lib/shopify_api/resources/transaction.rb +1 -0
  134. data/lib/shopify_api/resources/usage_charge.rb +1 -0
  135. data/lib/shopify_api/resources/user.rb +1 -0
  136. data/lib/shopify_api/resources/variant.rb +35 -0
  137. data/lib/shopify_api/resources/webhook.rb +1 -0
  138. data/lib/shopify_api/session.rb +109 -45
  139. data/lib/shopify_api/version.rb +2 -1
  140. data/lib/verify_docs.rb +8 -0
  141. data/service.yml +8 -0
  142. data/shopify_api.gemspec +19 -8
  143. data/test/abandoned_checkouts_test.rb +29 -0
  144. data/test/access_scope_test.rb +23 -0
  145. data/test/access_token_test.rb +6 -5
  146. data/test/active_resource/json_errors_test.rb +6 -6
  147. data/test/api_access_test.rb +153 -0
  148. data/test/api_permission_test.rb +9 -0
  149. data/test/api_version_test.rb +157 -0
  150. data/test/application_charge_test.rb +30 -27
  151. data/test/application_credit_test.rb +10 -9
  152. data/test/article_test.rb +34 -35
  153. data/test/asset_test.rb +14 -6
  154. data/test/assigned_fulfillment_order_test.rb +78 -0
  155. data/test/base_test.rb +147 -59
  156. data/test/blog_test.rb +4 -3
  157. data/test/carrier_service_test.rb +7 -6
  158. data/test/cart_test.rb +2 -1
  159. data/test/checkouts_test.rb +72 -4
  160. data/test/collect_test.rb +4 -3
  161. data/test/collection_listing_test.rb +56 -13
  162. data/test/collection_publication_test.rb +40 -0
  163. data/test/collection_test.rb +50 -0
  164. data/test/countable_test.rb +3 -2
  165. data/test/currency_test.rb +21 -0
  166. data/test/custom_collection_test.rb +4 -3
  167. data/test/customer_saved_search_test.rb +18 -8
  168. data/test/customer_test.rb +22 -14
  169. data/test/detailed_log_subscriber_test.rb +113 -19
  170. data/test/discount_code_batch_test.rb +41 -0
  171. data/test/discount_code_test.rb +22 -16
  172. data/test/draft_order_test.rb +68 -52
  173. data/test/fixtures/abandoned_checkout.json +184 -0
  174. data/test/fixtures/abandoned_checkouts.json +186 -0
  175. data/test/fixtures/access_scopes.json +10 -0
  176. data/test/fixtures/api_versions.json +38 -0
  177. data/test/fixtures/apis.json +42 -0
  178. data/test/fixtures/assigned_fulfillment_orders.json +80 -0
  179. data/test/fixtures/checkout.json +160 -0
  180. data/test/fixtures/checkouts.json +25 -49
  181. data/test/fixtures/collection.json +17 -0
  182. data/test/fixtures/collection_listing_product_ids2.json +1 -0
  183. data/test/fixtures/collection_products.json +47 -0
  184. data/test/fixtures/collection_publication.json +11 -0
  185. data/test/fixtures/collection_publications.json +13 -0
  186. data/test/fixtures/currencies.json +25 -0
  187. data/test/fixtures/discount_code_batch.json +14 -0
  188. data/test/fixtures/discount_code_batch_discount_codes.json +21 -0
  189. data/test/fixtures/fulfillment_order.json +39 -0
  190. data/test/fixtures/fulfillment_order_locations_for_move.json +18 -0
  191. data/test/fixtures/fulfillment_orders.json +80 -0
  192. data/test/fixtures/fulfillments.json +53 -0
  193. data/test/fixtures/graphql/2019-10.json +1083 -0
  194. data/test/fixtures/graphql/dummy_schema.rb +16 -0
  195. data/test/fixtures/graphql/unstable.json +1083 -0
  196. data/test/fixtures/inventory_level.json +7 -0
  197. data/test/fixtures/inventory_levels.json +24 -0
  198. data/test/fixtures/order_with_properties.json +373 -0
  199. data/test/fixtures/payment.json +7 -0
  200. data/test/fixtures/payments.json +9 -0
  201. data/test/fixtures/ping/conversation.json +1 -0
  202. data/test/fixtures/ping/failed_delivery_confirmation.json +1 -0
  203. data/test/fixtures/ping/message.json +1 -0
  204. data/test/fixtures/ping/successful_delivery_confirmation.json +1 -0
  205. data/test/fixtures/product_listing_product_ids.json +1 -1
  206. data/test/fixtures/product_listing_product_ids2.json +1 -0
  207. data/test/fixtures/product_publication.json +11 -0
  208. data/test/fixtures/product_publications.json +13 -0
  209. data/test/fixtures/publications.json +9 -0
  210. data/test/fixtures/shipping_rates.json +12 -0
  211. data/test/fixtures/smart_collection_products.json +155 -0
  212. data/test/fixtures/tender_transactions.json +52 -0
  213. data/test/fulfillment_event_test.rb +31 -26
  214. data/test/fulfillment_order_test.rb +530 -0
  215. data/test/fulfillment_order_test_helper.rb +8 -0
  216. data/test/fulfillment_request_test.rb +10 -8
  217. data/test/fulfillment_service_test.rb +13 -12
  218. data/test/fulfillment_test.rb +198 -20
  219. data/test/fulfillment_v2_test.rb +66 -0
  220. data/test/gift_card_test.rb +6 -4
  221. data/test/graphql/http_client_test.rb +26 -0
  222. data/test/graphql_test.rb +190 -0
  223. data/test/image_test.rb +19 -17
  224. data/test/inventory_level_test.rb +68 -0
  225. data/test/lib/webmock_extensions/last_request.rb +16 -0
  226. data/test/limits_test.rb +4 -3
  227. data/test/location_test.rb +15 -0
  228. data/test/marketing_event_test.rb +21 -21
  229. data/test/message_enricher_test.rb +45 -0
  230. data/test/meta_test.rb +47 -0
  231. data/test/metafield_test.rb +30 -20
  232. data/test/order_risk_test.rb +17 -16
  233. data/test/order_test.rb +110 -17
  234. data/test/pagination_test.rb +290 -0
  235. data/test/payment_test.rb +19 -0
  236. data/test/policy_test.rb +6 -5
  237. data/test/price_rule_test.rb +20 -15
  238. data/test/product_listing_test.rb +72 -15
  239. data/test/product_publication_test.rb +40 -0
  240. data/test/product_test.rb +80 -19
  241. data/test/publication_test.rb +12 -0
  242. data/test/recurring_application_charge_test.rb +105 -50
  243. data/test/redirect_test.rb +4 -3
  244. data/test/refund_test.rb +22 -17
  245. data/test/report_test.rb +12 -10
  246. data/test/resource_feedback_test.rb +14 -13
  247. data/test/script_tag_test.rb +10 -9
  248. data/test/session_test.rb +497 -111
  249. data/test/shipping_rate_test.rb +17 -0
  250. data/test/shipping_zone_test.rb +4 -3
  251. data/test/shop_test.rb +47 -33
  252. data/test/smart_collection_test.rb +5 -4
  253. data/test/storefront_access_token_test.rb +13 -15
  254. data/test/tax_service_test.rb +7 -3
  255. data/test/tender_transaction_test.rb +18 -0
  256. data/test/test_helper.rb +98 -67
  257. data/test/transaction_test.rb +4 -3
  258. data/test/usage_charge_test.rb +12 -8
  259. data/test/user_test.rb +4 -3
  260. data/test/variant_test.rb +50 -20
  261. data/test/webhook_test.rb +10 -7
  262. metadata +196 -37
  263. data/.travis.yml +0 -36
  264. data/CHANGELOG +0 -292
  265. data/Gemfile_ar30 +0 -6
  266. data/Gemfile_ar31 +0 -6
  267. data/Gemfile_ar32 +0 -6
  268. data/Gemfile_ar40 +0 -6
  269. data/bin/shopify +0 -3
  270. data/lib/active_resource/base_ext.rb +0 -21
  271. data/lib/active_resource/disable_prefix_check.rb +0 -36
  272. data/lib/active_resource/to_query.rb +0 -10
  273. data/lib/shopify_api/json_format.rb +0 -18
  274. data/lib/shopify_api/resources/discount.rb +0 -11
  275. data/lib/shopify_api/resources/o_auth.rb +0 -9
  276. data/test/discount_test.rb +0 -52
  277. data/test/fixtures/discount.json +0 -17
  278. data/test/fixtures/discount_disabled.json +0 -17
  279. data/test/fixtures/discounts.json +0 -34
  280. data/test/fixtures/o_auth_revoke.json +0 -5
  281. data/test/o_auth_test.rb +0 -8
@@ -1,79 +1,82 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class ApplicationChargeTest < Test::Unit::TestCase
4
-
5
5
  def test_application_charge_create
6
- fake "application_charges", :method => :post, :status => 201, :body => load_fixture('application_charge')
6
+ fake("application_charges", method: :post, status: 201, body: load_fixture('application_charge'))
7
7
 
8
8
  charge = ShopifyAPI::ApplicationCharge.create(
9
- name: "iPod Cleaning",
10
- price: 5.00,
11
- return_url: "http://google.com"
9
+ name: "iPod Cleaning",
10
+ price: 5.00,
11
+ return_url: "http://google.com"
12
12
  )
13
13
 
14
- assert_equal 'https://this-is-my-test-shop.myshopify.com/admin/charges/803742/confirm_application_charge?signature=BAhpA55DDA%3D%3D--55b44e274e438c619be4631c804abcbcb6ee915a', charge.confirmation_url
14
+ assert_equal(
15
+ 'https://this-is-my-test-shop.myshopify.com/admin/charges/803742/confirm_application_charge?' \
16
+ 'signature=BAhpA55DDA%3D%3D--55b44e274e438c619be4631c804abcbcb6ee915a',
17
+ charge.confirmation_url
18
+ )
15
19
  end
16
20
 
17
21
  def test_get_application_charge
18
- fake "application_charges/803742", :method => :get, :status => 201, :body => load_fixture('application_charge')
22
+ fake("application_charges/803742", method: :get, status: 201, body: load_fixture('application_charge'))
19
23
 
20
24
  charge = ShopifyAPI::ApplicationCharge.find(803742)
21
25
 
22
- assert_equal "iPod Cleaning", charge.name
26
+ assert_equal("iPod Cleaning", charge.name)
23
27
  end
24
28
 
25
29
  def test_list_application_charges
26
- fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
30
+ fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
27
31
 
28
32
  charges = ShopifyAPI::ApplicationCharge.find(:all)
29
33
 
30
- assert_equal 4, charges.size
31
- assert_equal "iPhone Case", charges.last.name
34
+ assert_equal(4, charges.size)
35
+ assert_equal("iPhone Case", charges.last.name)
32
36
  end
33
37
 
34
38
  def test_list_pending_application_charges
35
- fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
39
+ fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
36
40
 
37
41
  pending_charges = ShopifyAPI::ApplicationCharge.pending
38
42
 
39
- assert_equal 1, pending_charges.size
40
- assert_equal "Screen Replacement", pending_charges.first.name
43
+ assert_equal(1, pending_charges.size)
44
+ assert_equal("Screen Replacement", pending_charges.first.name)
41
45
  end
42
46
 
43
47
  def test_list_expired_application_charges
44
- fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
48
+ fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
45
49
 
46
50
  expired_charges = ShopifyAPI::ApplicationCharge.expired
47
51
 
48
- assert_equal 1, expired_charges.size
49
- assert_equal "iPod Cleaning", expired_charges.first.name
52
+ assert_equal(1, expired_charges.size)
53
+ assert_equal("iPod Cleaning", expired_charges.first.name)
50
54
  end
51
55
 
52
56
  def test_list_accepted_application_charges
53
- fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
57
+ fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
54
58
 
55
59
  accepted_charges = ShopifyAPI::ApplicationCharge.accepted
56
60
 
57
- assert_equal 1, accepted_charges.size
58
- assert_equal "iPhone Case", accepted_charges.first.name
61
+ assert_equal(1, accepted_charges.size)
62
+ assert_equal("iPhone Case", accepted_charges.first.name)
59
63
  end
60
64
 
61
65
  def test_list_declined_application_charges
62
- fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
66
+ fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
63
67
 
64
68
  declined_charges = ShopifyAPI::ApplicationCharge.declined
65
69
 
66
- assert_equal 1, declined_charges.size
67
- assert_equal "Magic Mouse", declined_charges.first.name
70
+ assert_equal(1, declined_charges.size)
71
+ assert_equal("Magic Mouse", declined_charges.first.name)
68
72
  end
69
73
 
70
74
  def test_activate_application_charge
71
- fake "application_charges", :method => :get, :status => 201, :body => load_fixture('application_charges')
72
- fake "application_charges/803740/activate", :method => :post, :status => 200, :body => "{}"
75
+ fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
76
+ fake("application_charges/803740/activate", method: :post, status: 200, body: "{}")
73
77
 
74
78
  charge = ShopifyAPI::ApplicationCharge.accepted
75
79
 
76
- assert charge.last.activate
80
+ assert(charge.last.activate)
77
81
  end
78
-
79
82
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class ApplicationCreditTest < Test::Unit::TestCase
4
5
  def test_application_credit_create
5
- fake "application_credits", method: :post, status: 201, body: load_fixture('application_credit')
6
+ fake("application_credits", method: :post, status: 201, body: load_fixture('application_credit'))
6
7
 
7
8
  credit = ShopifyAPI::ApplicationCredit.create(
8
9
  description: "refund for application charge",
@@ -11,25 +12,25 @@ class ApplicationCreditTest < Test::Unit::TestCase
11
12
  shop_id: 487168
12
13
  )
13
14
 
14
- assert_equal 'refund for application charge', credit.description
15
- assert_equal '5.00', credit.amount
15
+ assert_equal('refund for application charge', credit.description)
16
+ assert_equal('5.00', credit.amount)
16
17
  end
17
18
 
18
19
  def test_get_application_credit
19
- fake "application_credits/803742", method: :get, status: 201, body: load_fixture('application_credit')
20
+ fake("application_credits/803742", method: :get, status: 201, body: load_fixture('application_credit'))
20
21
 
21
22
  credit = ShopifyAPI::ApplicationCredit.find(803742)
22
23
 
23
- assert_equal 'refund for application charge', credit.description
24
- assert_equal '5.00', credit.amount
24
+ assert_equal('refund for application charge', credit.description)
25
+ assert_equal('5.00', credit.amount)
25
26
  end
26
27
 
27
28
  def test_list_application_credits
28
- fake "application_credits", method: :get, status: 201, body: load_fixture('application_credits')
29
+ fake("application_credits", method: :get, status: 201, body: load_fixture('application_credits'))
29
30
 
30
31
  credit = ShopifyAPI::ApplicationCredit.find(:all)
31
32
 
32
- assert_equal 2, credit.size
33
- assert_equal '10.00', credit.last.amount
33
+ assert_equal(2, credit.size)
34
+ assert_equal('10.00', credit.last.amount)
34
35
  end
35
36
  end
data/test/article_test.rb CHANGED
@@ -1,73 +1,72 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class ArticleTest < Test::Unit::TestCase
4
-
5
5
  def test_create_article
6
- fake "blogs/1008414260/articles", :method => :post, :body => load_fixture('article')
7
- article = ShopifyAPI::Article.new(:blog_id => 1008414260)
6
+ fake("blogs/1008414260/articles", method: :post, body: load_fixture('article'))
7
+ article = ShopifyAPI::Article.new(blog_id: 1008414260)
8
8
  article.save
9
- assert_equal "First Post", article.title
9
+ assert_equal("First Post", article.title)
10
10
  end
11
11
 
12
12
  def test_get_article
13
- fake "articles/6242736", :method => :get, :body => load_fixture('article')
13
+ fake("articles/6242736", method: :get, body: load_fixture('article'))
14
14
  article = ShopifyAPI::Article.find(6242736)
15
- assert_equal "First Post", article.title
16
- assert_equal 1008414260, article.blog_id
15
+ assert_equal("First Post", article.title)
16
+ assert_equal(1008414260, article.blog_id)
17
17
  end
18
18
 
19
19
  def test_get_articles
20
- fake "articles", :method => :get, :body => load_fixture('articles')
20
+ fake("articles", method: :get, body: load_fixture('articles'))
21
21
  articles = ShopifyAPI::Article.all
22
- assert_equal 3, articles.length
23
- assert_equal 1008414260, articles.first.blog_id
22
+ assert_equal(3, articles.length)
23
+ assert_equal(1008414260, articles.first.blog_id)
24
24
  end
25
25
 
26
26
  def test_get_articles_namespaced
27
- fake "blogs/1008414260/articles", :method => :get, :body => load_fixture('articles')
28
- articles = ShopifyAPI::Article.find(:all, :params => {:blog_id => 1008414260})
29
- assert_equal 3, articles.length
30
- assert_equal 1008414260, articles.first.blog_id
27
+ fake("blogs/1008414260/articles", method: :get, body: load_fixture('articles'))
28
+ articles = ShopifyAPI::Article.find(:all, params: { blog_id: 1008414260 })
29
+ assert_equal(3, articles.length)
30
+ assert_equal(1008414260, articles.first.blog_id)
31
31
  end
32
32
 
33
33
  def test_get_article_namespaced
34
- fake "blogs/1008414260/articles/6242736", :method => :get, :body => load_fixture('article')
35
- article = ShopifyAPI::Article.find(6242736, :params => {:blog_id => 1008414260})
36
- assert_equal "First Post", article.title
37
- assert_equal 1008414260, article.blog_id
34
+ fake("blogs/1008414260/articles/6242736", method: :get, body: load_fixture('article'))
35
+ article = ShopifyAPI::Article.find(6242736, params: { blog_id: 1008414260 })
36
+ assert_equal("First Post", article.title)
37
+ assert_equal(1008414260, article.blog_id)
38
38
  end
39
39
 
40
40
  def test_get_authors
41
- fake "articles/authors", :method => :get, :body => load_fixture('authors')
41
+ fake("articles/authors", method: :get, body: load_fixture('authors'))
42
42
  authors = ShopifyAPI::Article.authors
43
- assert_equal "Shopify", authors.first
44
- assert_equal "development shop", authors.last
43
+ assert_equal("Shopify", authors.first)
44
+ assert_equal("development shop", authors.last)
45
45
  end
46
46
 
47
47
  def test_get_authors_for_blog_id
48
- fake "blogs/1008414260/articles/authors", :method => :get, :body => load_fixture('authors')
49
- authors = ShopifyAPI::Article.authors(:blog_id => 1008414260)
50
- assert_equal 3, authors.length
48
+ fake("blogs/1008414260/articles/authors", method: :get, body: load_fixture('authors'))
49
+ authors = ShopifyAPI::Article.authors(blog_id: 1008414260)
50
+ assert_equal(3, authors.length)
51
51
  end
52
52
 
53
53
  def test_get_tags
54
- fake "articles/tags", :method => :get, :body => load_fixture('tags')
54
+ fake("articles/tags", method: :get, body: load_fixture('tags'))
55
55
  tags = ShopifyAPI::Article.tags
56
- assert_equal "consequuntur", tags.first
57
- assert_equal "repellendus", tags.last
56
+ assert_equal("consequuntur", tags.first)
57
+ assert_equal("repellendus", tags.last)
58
58
  end
59
59
 
60
60
  def test_get_tags_for_blog_id
61
- fake "blogs/1008414260/articles/tags", :method => :get, :body => load_fixture('tags')
62
- tags = ShopifyAPI::Article.tags(:blog_id => 1008414260)
63
- assert_equal "consequuntur", tags.first
64
- assert_equal "repellendus", tags.last
61
+ fake("blogs/1008414260/articles/tags", method: :get, body: load_fixture('tags'))
62
+ tags = ShopifyAPI::Article.tags(blog_id: 1008414260)
63
+ assert_equal("consequuntur", tags.first)
64
+ assert_equal("repellendus", tags.last)
65
65
  end
66
66
 
67
67
  def test_get_popular_tags
68
- fake "articles/tags.json?limit=1&popular=1", :extension => false, :method => :get, :body => load_fixture('tags')
69
- tags = ShopifyAPI::Article.tags(:popular => 1, :limit => 1)
70
- assert_equal 3, tags.length
68
+ fake("articles/tags.json?limit=1&popular=1", extension: false, method: :get, body: load_fixture('tags'))
69
+ tags = ShopifyAPI::Article.tags(popular: 1, limit: 1)
70
+ assert_equal(3, tags.length)
71
71
  end
72
-
73
72
  end
data/test/asset_test.rb CHANGED
@@ -1,18 +1,26 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class AssetTest < Test::Unit::TestCase
4
5
  def test_get_assetss
5
- fake "themes/1/assets", :method => :get, :body => load_fixture('assets')
6
- v = ShopifyAPI::Asset.find(:all, :params => {:theme_id => 1})
6
+ fake("themes/1/assets", method: :get, body: load_fixture('assets'))
7
+ ShopifyAPI::Asset.find(:all, params: { theme_id: 1 })
7
8
  end
8
9
 
9
10
  def test_get_asset_namespaced
10
- fake "themes/1/assets.json?asset%5Bkey%5D=templates%2Findex.liquid&theme_id=1", :extension=> false, :method => :get, :body => load_fixture('asset')
11
- v = ShopifyAPI::Asset.find('templates/index.liquid', :params => {:theme_id => 1})
11
+ fake(
12
+ "themes/1/assets.json?asset%5Bkey%5D=templates%2Findex.liquid&theme_id=1",
13
+ extension: false,
14
+ method: :get,
15
+ body: load_fixture('asset')
16
+ )
17
+ ShopifyAPI::Asset.find('templates/index.liquid', params: { theme_id: 1 })
12
18
  end
13
19
 
14
20
  def test_get_asset
15
- fake "assets.json?asset%5Bkey%5D=templates%2Findex.liquid", :extension=> false, :method => :get, :body => load_fixture('asset')
16
- v = ShopifyAPI::Asset.find('templates/index.liquid')
21
+ fake(
22
+ "assets.json?asset%5Bkey%5D=templates%2Findex.liquid", extension: false, method: :get, body: load_fixture('asset')
23
+ )
24
+ ShopifyAPI::Asset.find('templates/index.liquid')
17
25
  end
18
26
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+ require 'fulfillment_order_test_helper'
4
+
5
+ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
6
+ include FulfillmentOrderTestHelper
7
+
8
+ def setup
9
+ super
10
+ @url_prefix = url_prefix_for_activated_session_for('2020-01')
11
+ @fulfillment_order_fixture = load_fixture('assigned_fulfillment_orders')
12
+ end
13
+
14
+ context "AssignedFulfillmentOrder" do
15
+ context ".new" do
16
+ should "raise NotImplementedError when api_version is older than 2020-01" do
17
+ url_prefix_for_activated_session_for('2019-10')
18
+
19
+ assert_raises(NotImplementedError) do
20
+ ShopifyAPI::AssignedFulfillmentOrder.new(ActiveSupport::JSON.decode(@fulfillment_order_fixture))
21
+ end
22
+ end
23
+ end
24
+
25
+ context "#all" do
26
+ should "raise NotImplementedError when api_version is older than 2020-01" do
27
+ @url_prefix = url_prefix_for_activated_session_for('2019-10')
28
+
29
+ fake 'assigned_fulfillment_orders',
30
+ url: "#{@url_prefix}/assigned_fulfillment_orders.json",
31
+ method: :get,
32
+ body: @fulfillment_order_fixture,
33
+ extension: false
34
+
35
+ assert_raises(NotImplementedError) do
36
+ ShopifyAPI::AssignedFulfillmentOrder.all(params: { assigned_status: 'cancellation_requested' })
37
+ end
38
+ end
39
+
40
+ should "list assigned fulfillment orders by assigned_status" do
41
+ fake 'assigned_fulfillment_orders',
42
+ url: "#{@url_prefix}/assigned_fulfillment_orders.json?assigned_status=cancellation_requested",
43
+ method: :get,
44
+ body: @fulfillment_order_fixture,
45
+ extension: false
46
+
47
+ assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
48
+ params: { assigned_status: 'cancellation_requested' }
49
+ )
50
+
51
+ assert_equal 2, assigned_fulfillment_orders.count
52
+ assigned_fulfillment_orders.each do |fulfillment_order|
53
+ assert fulfillment_order.is_a?(ShopifyAPI::FulfillmentOrder)
54
+ assert_equal 'in_progress', fulfillment_order.status
55
+ assert_equal 'cancellation_accepted', fulfillment_order.request_status
56
+ end
57
+ end
58
+
59
+ should "be able to list assigned fulfillment orders by location_ids" do
60
+ assigned_location_id = 905684977
61
+ fake 'assigned_fulfillment_orders',
62
+ url: "#{@url_prefix}/assigned_fulfillment_orders.json?location_ids%5B%5D=#{assigned_location_id}",
63
+ method: :get,
64
+ body: @fulfillment_order_fixture, extension: false
65
+
66
+ assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
67
+ params: { location_ids: [assigned_location_id] }
68
+ )
69
+
70
+ assert_equal 2, assigned_fulfillment_orders.count
71
+ assigned_fulfillment_orders.each do |fulfillment_order|
72
+ assert fulfillment_order.is_a?(ShopifyAPI::FulfillmentOrder)
73
+ assert_equal assigned_location_id, fulfillment_order.assigned_location_id
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
data/test/base_test.rb CHANGED
@@ -1,120 +1,205 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
-
3
+ require "active_support/log_subscriber/test_helper"
3
4
 
4
5
  class BaseTest < Test::Unit::TestCase
5
-
6
6
  def setup
7
- @session1 = ShopifyAPI::Session.new('shop1.myshopify.com', 'token1')
8
- @session2 = ShopifyAPI::Session.new('shop2.myshopify.com', 'token2')
7
+ super
8
+ @session1 = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
9
+ @session2 = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: '2019-01')
9
10
  end
10
11
 
11
12
  def teardown
13
+ super
12
14
  clear_header('X-Custom')
13
15
  end
14
16
 
15
17
  test '#activate_session should set site and headers for given session' do
16
- ShopifyAPI::Base.activate_session @session1
18
+ ShopifyAPI::Base.activate_session(@session1)
17
19
 
18
- assert_nil ActiveResource::Base.site
19
- assert_equal 'https://shop1.myshopify.com/admin', ShopifyAPI::Base.site.to_s
20
- assert_equal 'https://shop1.myshopify.com/admin', ShopifyAPI::Shop.site.to_s
20
+ assert_nil(ActiveResource::Base.site)
21
+ assert_equal('https://shop1.myshopify.com', ShopifyAPI::Base.site.to_s)
22
+ assert_equal('https://shop1.myshopify.com', ShopifyAPI::Shop.site.to_s)
21
23
 
22
- assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token']
23
- assert_equal 'token1', ShopifyAPI::Base.headers['X-Shopify-Access-Token']
24
- assert_equal 'token1', ShopifyAPI::Shop.headers['X-Shopify-Access-Token']
24
+ assert_nil(ActiveResource::Base.headers['X-Shopify-Access-Token'])
25
+ assert_equal('token1', ShopifyAPI::Base.headers['X-Shopify-Access-Token'])
26
+ assert_equal('token1', ShopifyAPI::Shop.headers['X-Shopify-Access-Token'])
25
27
  end
26
28
 
27
29
  test '#clear_session should clear base site settings from Base' do
28
30
  ShopifyAPI::Base.site = "https://foo:bar@www.zombo.com"
29
31
 
30
- assert_equal "foo", ShopifyAPI::Base.user
31
- assert_equal "bar", ShopifyAPI::Base.password
32
+ assert_equal("foo", ShopifyAPI::Base.user)
33
+ assert_equal("bar", ShopifyAPI::Base.password)
34
+
35
+ ShopifyAPI::Base.clear_session
36
+
37
+ assert_nil(ShopifyAPI::Base.user)
38
+ assert_nil(ShopifyAPI::Base.password)
39
+ assert_nil(ShopifyAPI::Base.site)
40
+ end
41
+
42
+ # test to check session reset api version remains the same after session reset
43
+ test '#clear_session should not change the api_version' do
44
+ ShopifyAPI::Base.site = "https://zoo:lion@www.zoo.com"
45
+
46
+ assert_equal("zoo", ShopifyAPI::Base.user)
47
+ assert_equal("lion", ShopifyAPI::Base.password)
32
48
 
33
49
  ShopifyAPI::Base.clear_session
34
50
 
35
- assert_equal nil, ShopifyAPI::Base.user
36
- assert_equal nil, ShopifyAPI::Base.password
37
- assert_equal nil, ShopifyAPI::Base.site
51
+ assert_nil(ShopifyAPI::Base.user)
52
+ assert_nil(ShopifyAPI::Base.password)
53
+ assert_nil(ShopifyAPI::Base.site)
54
+ assert_equal(ShopifyAPI::Base.api_version, @session1.api_version)
38
55
  end
39
56
 
40
57
  test '#clear_session should clear site and headers from Base' do
41
- ShopifyAPI::Base.activate_session @session1
58
+ ShopifyAPI::Base.activate_session(@session1)
42
59
  ShopifyAPI::Base.clear_session
43
60
 
44
- assert_nil ActiveResource::Base.site
45
- assert_nil ShopifyAPI::Base.site
46
- assert_nil ShopifyAPI::Shop.site
61
+ assert_nil(ActiveResource::Base.site)
62
+ assert_nil(ShopifyAPI::Base.site)
63
+ assert_nil(ShopifyAPI::Shop.site)
47
64
 
48
- assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token']
49
- assert_nil ShopifyAPI::Base.headers['X-Shopify-Access-Token']
50
- assert_nil ShopifyAPI::Shop.headers['X-Shopify-Access-Token']
65
+ assert_nil(ActiveResource::Base.headers['X-Shopify-Access-Token'])
66
+ assert_nil(ShopifyAPI::Base.headers['X-Shopify-Access-Token'])
67
+ assert_nil(ShopifyAPI::Shop.headers['X-Shopify-Access-Token'])
51
68
  end
52
69
 
53
70
  test '#activate_session with one session, then clearing and activating with another session should send request to correct shop' do
54
- ShopifyAPI::Base.activate_session @session1
71
+ ShopifyAPI::Base.activate_session(@session1)
55
72
  ShopifyAPI::Base.clear_session
56
- ShopifyAPI::Base.activate_session @session2
73
+ ShopifyAPI::Base.activate_session(@session2)
57
74
 
58
- assert_nil ActiveResource::Base.site
59
- assert_equal 'https://shop2.myshopify.com/admin', ShopifyAPI::Base.site.to_s
60
- assert_equal 'https://shop2.myshopify.com/admin', ShopifyAPI::Shop.site.to_s
75
+ assert_nil(ActiveResource::Base.site)
76
+ assert_equal('https://shop2.myshopify.com', ShopifyAPI::Base.site.to_s)
77
+ assert_equal('https://shop2.myshopify.com', ShopifyAPI::Shop.site.to_s)
61
78
 
62
- assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token']
63
- assert_equal 'token2', ShopifyAPI::Base.headers['X-Shopify-Access-Token']
64
- assert_equal 'token2', ShopifyAPI::Shop.headers['X-Shopify-Access-Token']
79
+ assert_nil(ActiveResource::Base.headers['X-Shopify-Access-Token'])
80
+ assert_equal('token2', ShopifyAPI::Base.headers['X-Shopify-Access-Token'])
81
+ assert_equal('token2', ShopifyAPI::Shop.headers['X-Shopify-Access-Token'])
65
82
  end
66
83
 
67
84
  test '#activate_session with nil raises an InvalidSessionError' do
68
- assert_raises ShopifyAPI::Base::InvalidSessionError do
69
- ShopifyAPI::Base.activate_session nil
85
+ assert_raises(ShopifyAPI::Base::InvalidSessionError) do
86
+ ShopifyAPI::Base.activate_session(nil)
70
87
  end
71
88
  end
72
89
 
73
90
  test "#delete should send custom headers with request" do
74
- ShopifyAPI::Base.activate_session @session1
91
+ ShopifyAPI::Base.activate_session(@session1)
75
92
  ShopifyAPI::Base.headers['X-Custom'] = 'abc'
76
- ShopifyAPI::Base.connection.expects(:delete).with('/admin/bases/1.json', has_entry('X-Custom', 'abc'))
77
- ShopifyAPI::Base.delete "1"
93
+ ShopifyAPI::Base.connection
94
+ .expects(:delete)
95
+ .with('/admin/api/2019-01/bases/1.json', has_entry('X-Custom', 'abc'))
96
+ ShopifyAPI::Base.delete("1")
78
97
  end
79
98
 
80
99
  test "#headers includes the User-Agent" do
81
100
  assert_not_includes ActiveResource::Base.headers.keys, 'User-Agent'
82
- assert_includes ShopifyAPI::Base.headers.keys, 'User-Agent'
101
+ assert_includes(ShopifyAPI::Base.headers.keys, 'User-Agent')
83
102
  thread = Thread.new do
84
- assert_includes ShopifyAPI::Base.headers.keys, 'User-Agent'
103
+ assert_includes(ShopifyAPI::Base.headers.keys, 'User-Agent')
85
104
  end
86
105
  thread.join
87
106
  end
88
107
 
89
- if ActiveResource::VERSION::MAJOR >= 4
90
- test "#headers propagates changes to subclasses" do
91
- ShopifyAPI::Base.headers['X-Custom'] = "the value"
92
- assert_equal "the value", ShopifyAPI::Base.headers['X-Custom']
93
- assert_equal "the value", ShopifyAPI::Product.headers['X-Custom']
108
+ test "prefix= will forward to resource when the value does not start with admin" do
109
+ session = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
110
+ ShopifyAPI::Base.activate_session(session)
111
+ silence_warnings do
112
+ TestResource.prefix = 'a/regular/path/'
94
113
  end
95
114
 
96
- test "#headers clears changes to subclasses" do
97
- ShopifyAPI::Base.headers['X-Custom'] = "the value"
98
- assert_equal "the value", ShopifyAPI::Product.headers['X-Custom']
99
- ShopifyAPI::Base.headers['X-Custom'] = nil
100
- assert_nil ShopifyAPI::Product.headers['X-Custom']
115
+ assert_equal('/admin/api/2019-01/a/regular/path/', TestResource.prefix)
116
+ end
117
+
118
+ test "prefix= will raise an error if value starts with with /admin" do
119
+ assert_raises(ArgumentError) do
120
+ TestResource.prefix = '/admin/old/prefix/structure/'
101
121
  end
102
122
  end
103
123
 
104
- if ActiveResource::VERSION::MAJOR >= 5 || (ActiveResource::VERSION::MAJOR >= 4 && ActiveResource::VERSION::PRE == "threadsafe")
105
- test "#headers set in the main thread affect spawned threads" do
124
+ test "#headers propagates changes to subclasses" do
125
+ ShopifyAPI::Base.headers['X-Custom'] = "the value"
126
+ assert_equal("the value", ShopifyAPI::Base.headers['X-Custom'])
127
+ assert_equal("the value", ShopifyAPI::Product.headers['X-Custom'])
128
+ end
129
+
130
+ test "#headers clears changes to subclasses" do
131
+ ShopifyAPI::Base.headers['X-Custom'] = "the value"
132
+ assert_equal("the value", ShopifyAPI::Product.headers['X-Custom'])
133
+ ShopifyAPI::Base.headers['X-Custom'] = nil
134
+ assert_nil(ShopifyAPI::Product.headers['X-Custom'])
135
+ end
136
+
137
+ test "#headers set in the main thread affect spawned threads" do
138
+ ShopifyAPI::Base.headers['X-Custom'] = "the value"
139
+ Thread.new do
140
+ assert_equal("the value", ShopifyAPI::Base.headers['X-Custom'])
141
+ end.join
142
+ end
143
+
144
+ test "#headers set in spawned threads do not affect the main thread" do
145
+ Thread.new do
106
146
  ShopifyAPI::Base.headers['X-Custom'] = "the value"
107
- Thread.new do
108
- assert_equal "the value", ShopifyAPI::Base.headers['X-Custom']
109
- end.join
110
- end
147
+ end.join
148
+ assert_nil(ShopifyAPI::Base.headers['X-Custom'])
149
+ end
150
+
151
+ test "using a different version changes the url" do
152
+ release_2019_01 = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
153
+ unstable_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: :unstable)
154
+
155
+ fake(
156
+ "shop",
157
+ url: "https://shop1.myshopify.com/admin/api/2019-01/shop.json",
158
+ method: :get,
159
+ status: 201,
160
+ body: '{ "shop": { "id": 1 } }'
161
+ )
162
+ fake(
163
+ "shop",
164
+ url: "https://shop2.myshopify.com/admin/api/unstable/shop.json",
165
+ method: :get,
166
+ status: 201,
167
+ body: '{ "shop": { "id": 2 } }'
168
+ )
169
+
170
+ ShopifyAPI::Base.activate_session(release_2019_01)
171
+ assert_equal(1, ShopifyAPI::Shop.current.id)
172
+
173
+ ShopifyAPI::Base.activate_session(unstable_version)
174
+ assert_equal(2, ShopifyAPI::Shop.current.id)
175
+ end
176
+
177
+ test "#api_version= should set ApiVersion" do
178
+ ShopifyAPI::Base.api_version = '2019-04'
179
+ assert_equal('2019-04', ShopifyAPI::Base.api_version.to_s)
180
+ end
111
181
 
112
- test "#headers set in spawned threads do not affect the main thread" do
113
- Thread.new do
114
- ShopifyAPI::Base.headers['X-Custom'] = "the value"
115
- end.join
116
- assert_nil ShopifyAPI::Base.headers['X-Custom']
182
+ test "#api_version= nil should set ApiVersion to ShopifyAPI::ApiVersion::NullVersion" do
183
+ ShopifyAPI::Base.api_version = nil
184
+ assert_equal(ShopifyAPI::ApiVersion::NullVersion, ShopifyAPI::Base.api_version)
185
+ end
186
+
187
+ test "#api_version= ShopifyAPI::ApiVersion::NullVersion should set ApiVersion to ShopifyAPI::ApiVersion::NullVersion" do
188
+ ShopifyAPI::Base.api_version = ShopifyAPI::ApiVersion::NullVersion
189
+ assert_equal(ShopifyAPI::ApiVersion::NullVersion, ShopifyAPI::Base.api_version)
190
+ end
191
+
192
+ test "#version_validation! does not raise is api_version is newer or equal to minimum supported version" do
193
+ ShopifyAPI::Base.api_version = '2020-01'
194
+ assert_nil(ShopifyAPI::Base::version_validation!('2020-01'))
195
+ end
196
+
197
+ test "#version_validation! raises NotImplemetedError if api_version is older than minimum supported version" do
198
+ ShopifyAPI::Base.api_version = '2019-10'
199
+ exception = assert_raises(NotImplementedError) do
200
+ ShopifyAPI::Base::version_validation!('2020-01')
117
201
  end
202
+ assert_equal('The minimum supported version is 2020-01.', exception.message)
118
203
  end
119
204
 
120
205
  def clear_header(header)
@@ -122,4 +207,7 @@ class BaseTest < Test::Unit::TestCase
122
207
  klass.headers.delete(header)
123
208
  end
124
209
  end
210
+
211
+ class TestResource < ShopifyAPI::Base
212
+ end
125
213
  end