shopify_api 9.2.0 → 9.3.0

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 (190) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +36 -0
  3. data/.github/workflows/build.yml +41 -0
  4. data/.gitignore +0 -1
  5. data/.rubocop.yml +23 -3
  6. data/.rubocop_todo.yml +75 -0
  7. data/CHANGELOG.md +15 -0
  8. data/Gemfile +1 -0
  9. data/Gemfile.lock +151 -0
  10. data/Gemfile_ar51 +1 -1
  11. data/README.md +40 -30
  12. data/RELEASING +10 -6
  13. data/Rakefile +10 -6
  14. data/docs/graphql.md +1 -1
  15. data/docs/index.md +1 -1
  16. data/lib/active_resource/connection_ext.rb +1 -0
  17. data/lib/active_resource/detailed_log_subscriber.rb +6 -7
  18. data/lib/active_resource/json_errors.rb +8 -2
  19. data/lib/shopify_api.rb +8 -1
  20. data/lib/shopify_api/api_access.rb +57 -0
  21. data/lib/shopify_api/api_version.rb +6 -5
  22. data/lib/shopify_api/connection.rb +1 -0
  23. data/lib/shopify_api/countable.rb +3 -2
  24. data/lib/shopify_api/disable_prefix_check.rb +2 -2
  25. data/lib/shopify_api/events.rb +2 -1
  26. data/lib/shopify_api/graphql.rb +8 -6
  27. data/lib/shopify_api/limits.rb +3 -2
  28. data/lib/shopify_api/message_enricher.rb +11 -9
  29. data/lib/shopify_api/meta.rb +0 -1
  30. data/lib/shopify_api/metafields.rb +5 -4
  31. data/lib/shopify_api/pagination_link_headers.rb +4 -3
  32. data/lib/shopify_api/resources.rb +1 -0
  33. data/lib/shopify_api/resources/access_scope.rb +1 -1
  34. data/lib/shopify_api/resources/access_token.rb +1 -0
  35. data/lib/shopify_api/resources/address.rb +1 -0
  36. data/lib/shopify_api/resources/announcement.rb +2 -1
  37. data/lib/shopify_api/resources/application_charge.rb +1 -0
  38. data/lib/shopify_api/resources/application_credit.rb +1 -0
  39. data/lib/shopify_api/resources/article.rb +3 -2
  40. data/lib/shopify_api/resources/asset.rb +6 -5
  41. data/lib/shopify_api/resources/assigned_fulfillment_order.rb +1 -1
  42. data/lib/shopify_api/resources/base.rb +11 -6
  43. data/lib/shopify_api/resources/billing_address.rb +1 -0
  44. data/lib/shopify_api/resources/blog.rb +2 -1
  45. data/lib/shopify_api/resources/carrier_service.rb +1 -0
  46. data/lib/shopify_api/resources/cart.rb +2 -1
  47. data/lib/shopify_api/resources/collect.rb +1 -0
  48. data/lib/shopify_api/resources/collection_listing.rb +1 -0
  49. data/lib/shopify_api/resources/comment.rb +20 -5
  50. data/lib/shopify_api/resources/country.rb +1 -0
  51. data/lib/shopify_api/resources/custom_collection.rb +4 -3
  52. data/lib/shopify_api/resources/customer.rb +2 -1
  53. data/lib/shopify_api/resources/customer_group.rb +1 -0
  54. data/lib/shopify_api/resources/customer_invite.rb +1 -0
  55. data/lib/shopify_api/resources/customer_saved_search.rb +2 -1
  56. data/lib/shopify_api/resources/discount_code.rb +1 -0
  57. data/lib/shopify_api/resources/discount_code_batch.rb +4 -2
  58. data/lib/shopify_api/resources/draft_order.rb +1 -0
  59. data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
  60. data/lib/shopify_api/resources/event.rb +1 -0
  61. data/lib/shopify_api/resources/fulfillment.rb +12 -3
  62. data/lib/shopify_api/resources/fulfillment_event.rb +1 -0
  63. data/lib/shopify_api/resources/fulfillment_order.rb +30 -16
  64. data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +1 -0
  65. data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
  66. data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
  67. data/lib/shopify_api/resources/fulfillment_v2.rb +3 -2
  68. data/lib/shopify_api/resources/gift_card.rb +1 -0
  69. data/lib/shopify_api/resources/image.rb +2 -1
  70. data/lib/shopify_api/resources/inventory_level.rb +2 -3
  71. data/lib/shopify_api/resources/line_item.rb +4 -3
  72. data/lib/shopify_api/resources/location.rb +1 -1
  73. data/lib/shopify_api/resources/marketing_event.rb +1 -0
  74. data/lib/shopify_api/resources/metafield.rb +1 -0
  75. data/lib/shopify_api/resources/note_attribute.rb +1 -0
  76. data/lib/shopify_api/resources/option.rb +1 -0
  77. data/lib/shopify_api/resources/order.rb +2 -1
  78. data/lib/shopify_api/resources/order_risk.rb +1 -0
  79. data/lib/shopify_api/resources/page.rb +1 -0
  80. data/lib/shopify_api/resources/payment_details.rb +1 -0
  81. data/lib/shopify_api/resources/policy.rb +1 -0
  82. data/lib/shopify_api/resources/price_rule.rb +1 -1
  83. data/lib/shopify_api/resources/product.rb +14 -11
  84. data/lib/shopify_api/resources/product_listing.rb +1 -0
  85. data/lib/shopify_api/resources/province.rb +1 -0
  86. data/lib/shopify_api/resources/receipt.rb +1 -0
  87. data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
  88. data/lib/shopify_api/resources/redirect.rb +1 -0
  89. data/lib/shopify_api/resources/refund.rb +2 -1
  90. data/lib/shopify_api/resources/report.rb +1 -0
  91. data/lib/shopify_api/resources/resource_feedback.rb +1 -1
  92. data/lib/shopify_api/resources/rule.rb +1 -0
  93. data/lib/shopify_api/resources/script_tag.rb +1 -0
  94. data/lib/shopify_api/resources/shipping_address.rb +1 -0
  95. data/lib/shopify_api/resources/shipping_line.rb +1 -0
  96. data/lib/shopify_api/resources/shipping_zone.rb +1 -0
  97. data/lib/shopify_api/resources/shop.rb +2 -1
  98. data/lib/shopify_api/resources/smart_collection.rb +2 -2
  99. data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
  100. data/lib/shopify_api/resources/tax_line.rb +1 -0
  101. data/lib/shopify_api/resources/tax_service.rb +1 -0
  102. data/lib/shopify_api/resources/theme.rb +1 -0
  103. data/lib/shopify_api/resources/transaction.rb +1 -0
  104. data/lib/shopify_api/resources/usage_charge.rb +1 -0
  105. data/lib/shopify_api/resources/user.rb +1 -0
  106. data/lib/shopify_api/resources/variant.rb +16 -18
  107. data/lib/shopify_api/resources/webhook.rb +1 -0
  108. data/lib/shopify_api/session.rb +20 -12
  109. data/lib/shopify_api/version.rb +2 -1
  110. data/lib/verify_docs.rb +1 -0
  111. data/service.yml +1 -1
  112. data/shopify_api.gemspec +10 -4
  113. data/test/access_token_test.rb +6 -5
  114. data/test/active_resource/json_errors_test.rb +6 -6
  115. data/test/api_access_test.rb +153 -0
  116. data/test/api_version_test.rb +3 -3
  117. data/test/application_charge_test.rb +30 -27
  118. data/test/application_credit_test.rb +10 -9
  119. data/test/article_test.rb +34 -35
  120. data/test/asset_test.rb +14 -6
  121. data/test/assigned_fulfillment_order_test.rb +5 -4
  122. data/test/base_test.rb +55 -56
  123. data/test/blog_test.rb +4 -3
  124. data/test/carrier_service_test.rb +7 -6
  125. data/test/cart_test.rb +2 -1
  126. data/test/collect_test.rb +4 -3
  127. data/test/collection_listing_test.rb +21 -16
  128. data/test/collection_publication_test.rb +8 -8
  129. data/test/collection_test.rb +20 -19
  130. data/test/countable_test.rb +3 -2
  131. data/test/currency_test.rb +5 -5
  132. data/test/custom_collection_test.rb +4 -3
  133. data/test/customer_saved_search_test.rb +18 -8
  134. data/test/customer_test.rb +22 -14
  135. data/test/detailed_log_subscriber_test.rb +15 -11
  136. data/test/discount_code_batch_test.rb +11 -10
  137. data/test/discount_code_test.rb +21 -15
  138. data/test/draft_order_test.rb +68 -52
  139. data/test/fixtures/assigned_fulfillment_orders.json +2 -0
  140. data/test/fixtures/fulfillment_order.json +1 -0
  141. data/test/fixtures/fulfillment_orders.json +2 -0
  142. data/test/fulfillment_event_test.rb +31 -26
  143. data/test/fulfillment_order_test.rb +215 -147
  144. data/test/fulfillment_order_test_helper.rb +1 -0
  145. data/test/fulfillment_request_test.rb +10 -8
  146. data/test/fulfillment_service_test.rb +13 -12
  147. data/test/fulfillment_test.rb +81 -66
  148. data/test/fulfillment_v2_test.rb +16 -12
  149. data/test/gift_card_test.rb +6 -4
  150. data/test/graphql_test.rb +27 -27
  151. data/test/image_test.rb +19 -17
  152. data/test/inventory_level_test.rb +24 -15
  153. data/test/lib/webmock_extensions/last_request.rb +1 -1
  154. data/test/limits_test.rb +2 -1
  155. data/test/location_test.rb +2 -1
  156. data/test/marketing_event_test.rb +20 -20
  157. data/test/message_enricher_test.rb +6 -6
  158. data/test/meta_test.rb +7 -9
  159. data/test/metafield_test.rb +30 -20
  160. data/test/order_risk_test.rb +17 -16
  161. data/test/order_test.rb +43 -28
  162. data/test/pagination_test.rb +89 -56
  163. data/test/policy_test.rb +6 -5
  164. data/test/price_rule_test.rb +20 -15
  165. data/test/product_listing_test.rb +20 -20
  166. data/test/product_publication_test.rb +8 -8
  167. data/test/product_test.rb +44 -32
  168. data/test/publication_test.rb +3 -3
  169. data/test/recurring_application_charge_test.rb +104 -42
  170. data/test/redirect_test.rb +4 -3
  171. data/test/refund_test.rb +22 -17
  172. data/test/report_test.rb +12 -10
  173. data/test/resource_feedback_test.rb +14 -13
  174. data/test/script_tag_test.rb +10 -9
  175. data/test/session_test.rb +74 -46
  176. data/test/shipping_zone_test.rb +4 -3
  177. data/test/shop_test.rb +47 -33
  178. data/test/smart_collection_test.rb +5 -4
  179. data/test/storefront_access_token_test.rb +13 -15
  180. data/test/tax_service_test.rb +7 -4
  181. data/test/tender_transaction_test.rb +3 -3
  182. data/test/test_helper.rb +13 -11
  183. data/test/transaction_test.rb +4 -3
  184. data/test/usage_charge_test.rb +12 -8
  185. data/test/user_test.rb +4 -3
  186. data/test/variant_test.rb +23 -54
  187. data/test/webhook_test.rb +10 -7
  188. metadata +14 -9
  189. data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1027
  190. data/.travis.yml +0 -28
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
  class BlogTest < Test::Unit::TestCase
3
4
  test "blog creation" do
4
- fake "blogs", :method => :post, :status => 202, :body => load_fixture('blog')
5
- blog = ShopifyAPI::Blog.create(:title => "Test Blog")
6
- assert_equal '{"blog":{"title":"Test Blog"}}', WebMock.last_request.body
5
+ fake("blogs", method: :post, status: 202, body: load_fixture('blog'))
6
+ ShopifyAPI::Blog.create(title: "Test Blog")
7
+ assert_equal('{"blog":{"title":"Test Blog"}}', WebMock.last_request.body)
7
8
  end
8
9
  end
@@ -1,17 +1,18 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CarrierServiceTest < Test::Unit::TestCase
4
5
  test 'new should create carrier service' do
5
- fake "carrier_services", :method => :post, :body => load_fixture('carrier_service')
6
- carrier_service = ShopifyAPI::CarrierService.new(:name => "Some Postal Service")
6
+ fake("carrier_services", method: :post, body: load_fixture('carrier_service'))
7
+ carrier_service = ShopifyAPI::CarrierService.new(name: "Some Postal Service")
7
8
  carrier_service.save
8
- assert_equal "Some Postal Service" , carrier_service.name
9
+ assert_equal("Some Postal Service", carrier_service.name)
9
10
  end
10
11
 
11
12
  test 'find should return the carrier service' do
12
- fake "carrier_services/123456", :method => :get, :body => load_fixture('carrier_service')
13
+ fake("carrier_services/123456", method: :get, body: load_fixture('carrier_service'))
13
14
  carrier_service = ShopifyAPI::CarrierService.find(123456)
14
- assert_equal 123456 , carrier_service.id
15
- assert_equal "Some Postal Service", carrier_service.name
15
+ assert_equal(123456, carrier_service.id)
16
+ assert_equal("Some Postal Service", carrier_service.name)
16
17
  end
17
18
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CartTest < Test::Unit::TestCase
@@ -10,4 +11,4 @@ class CartTest < Test::Unit::TestCase
10
11
  assert_equal 1, carts.first.line_items.size
11
12
  assert_equal 'test', carts.first.line_items.first.title
12
13
  end
13
- end
14
+ end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CollectTest < Test::Unit::TestCase
4
5
  test "#create should create a collect" do
5
- fake "collects", :method => :post, :status => 201, :body => load_fixture('collect')
6
- link = ShopifyAPI::Collect.create(:product_id => 921728736, :collection_id => 841564295)
7
- assert_equal 841564295, link.id
6
+ fake("collects", method: :post, status: 201, body: load_fixture('collect'))
7
+ link = ShopifyAPI::Collect.create(product_id: 921728736, collection_id: 841564295)
8
+ assert_equal(841564295, link.id)
8
9
  end
9
10
  end
@@ -1,42 +1,47 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CollectionListingTest < Test::Unit::TestCase
4
-
5
5
  def test_get_collection_listings
6
- fake "collection_listings", method: :get, status: 201, body: load_fixture('collection_listings')
6
+ fake("collection_listings", method: :get, status: 201, body: load_fixture('collection_listings'))
7
7
 
8
8
  collection_listings = ShopifyAPI::CollectionListing.find(:all)
9
9
 
10
- assert_equal 1, collection_listings.count
11
- assert_equal 1, collection_listings.first.collection_id
12
- assert_equal 'Home page', collection_listings.first.title
10
+ assert_equal(1, collection_listings.count)
11
+ assert_equal(1, collection_listings.first.collection_id)
12
+ assert_equal('Home page', collection_listings.first.title)
13
13
  end
14
14
 
15
15
  def test_get_collection_listing
16
- fake "collection_listings/1", method: :get, status: 201, body: load_fixture('collection_listing')
16
+ fake("collection_listings/1", method: :get, status: 201, body: load_fixture('collection_listing'))
17
17
 
18
18
  collection_listing = ShopifyAPI::CollectionListing.find(1)
19
19
 
20
- assert_equal 1, collection_listing.collection_id
21
- assert_equal 'Home page', collection_listing.title
20
+ assert_equal(1, collection_listing.collection_id)
21
+ assert_equal('Home page', collection_listing.title)
22
22
  end
23
23
 
24
24
  def test_get_collection_listing_reload
25
- fake "collection_listings/1", method: :get, status: 201, body: load_fixture('collection_listing')
25
+ fake("collection_listings/1", method: :get, status: 201, body: load_fixture('collection_listing'))
26
26
 
27
27
  collection_listing = ShopifyAPI::CollectionListing.new(collection_id: 1)
28
28
  collection_listing.reload
29
29
 
30
- assert_equal 1, collection_listing.collection_id
31
- assert_equal 'Home page', collection_listing.title
30
+ assert_equal(1, collection_listing.collection_id)
31
+ assert_equal('Home page', collection_listing.title)
32
32
  end
33
33
 
34
34
  def test_get_collection_listing_product_ids
35
- fake "collection_listings/1/product_ids", method: :get, status: 201, body: load_fixture('collection_listing_product_ids')
35
+ fake(
36
+ "collection_listings/1/product_ids",
37
+ method: :get,
38
+ status: 201,
39
+ body: load_fixture('collection_listing_product_ids')
40
+ )
36
41
 
37
42
  collection_listing = ShopifyAPI::CollectionListing.new(collection_id: 1)
38
43
 
39
- assert_equal [1, 2], collection_listing.product_ids
44
+ assert_equal([1, 2], collection_listing.product_ids)
40
45
  end
41
46
 
42
47
  def test_get_collection_listing_product_ids_multi_page_with_cursor
@@ -61,8 +66,8 @@ class CollectionListingTest < Test::Unit::TestCase
61
66
  )
62
67
 
63
68
  product_ids = collection_listing.product_ids
64
- assert_equal [1, 2], product_ids
65
- assert product_ids.next_page?
69
+ assert_equal([1, 2], product_ids)
70
+ assert(product_ids.next_page?)
66
71
 
67
72
  fake(
68
73
  "collection_listings/1/product_ids",
@@ -74,6 +79,6 @@ class CollectionListingTest < Test::Unit::TestCase
74
79
  )
75
80
 
76
81
  next_page = product_ids.fetch_next_page
77
- assert_equal [3, 4], next_page
82
+ assert_equal([3, 4], next_page)
78
83
  end
79
84
  end
@@ -3,23 +3,23 @@ require 'test_helper'
3
3
 
4
4
  class CollectionPublicationTest < Test::Unit::TestCase
5
5
  def test_get_all_collection_publications
6
- fake 'publications/55650051/collection_publications', body: load_fixture('collection_publications')
6
+ fake('publications/55650051/collection_publications', body: load_fixture('collection_publications'))
7
7
  collection_publications = ShopifyAPI::CollectionPublication.find(:all, params: { publication_id: 55650051 })
8
8
 
9
- assert_equal 96062799894, collection_publications.first.id
10
- assert_equal 55650051, collection_publications.first.publication_id
9
+ assert_equal(96062799894, collection_publications.first.id)
10
+ assert_equal(55650051, collection_publications.first.publication_id)
11
11
  end
12
12
 
13
13
  def test_get_collection_publication
14
- fake 'publications/55650051/collection_publications/647162527768', body: load_fixture('collection_publication')
14
+ fake('publications/55650051/collection_publications/647162527768', body: load_fixture('collection_publication'))
15
15
  collection_publication = ShopifyAPI::CollectionPublication.find(647162527768, params: { publication_id: 55650051 })
16
16
 
17
- assert_equal 96062799894, collection_publication.id
18
- assert_equal 55650051, collection_publication.publication_id
17
+ assert_equal(96062799894, collection_publication.id)
18
+ assert_equal(55650051, collection_publication.publication_id)
19
19
  end
20
20
 
21
21
  def test_create_collection_publication
22
- fake 'publications/55650051/collection_publications', method: :post, body: load_fixture('collection_publication')
22
+ fake('publications/55650051/collection_publications', method: :post, body: load_fixture('collection_publication'))
23
23
  ShopifyAPI::CollectionPublication.create(
24
24
  publication_id: 55650051,
25
25
  published_at: "2018-01-29T14:06:08-05:00",
@@ -35,6 +35,6 @@ class CollectionPublicationTest < Test::Unit::TestCase
35
35
  },
36
36
  }.to_json
37
37
 
38
- assert_equal expected_body, WebMock.last_request.body
38
+ assert_equal(expected_body, WebMock.last_request.body)
39
39
  end
40
40
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CollectionTest < Test::Unit::TestCase
@@ -6,23 +7,23 @@ class CollectionTest < Test::Unit::TestCase
6
7
  ShopifyAPI::Base.activate_session(available_version)
7
8
 
8
9
  fake(
9
- 'collections',
10
- url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1.json',
11
- method: :get,
12
- status: 200,
13
- body: load_fixture('collection'),
14
- extension: false
10
+ 'collections',
11
+ url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1.json',
12
+ method: :get,
13
+ status: 200,
14
+ body: load_fixture('collection'),
15
+ extension: false
15
16
  )
16
17
 
17
18
  collection = ShopifyAPI::Collection.find(1)
18
19
 
19
20
  fake(
20
- 'products',
21
- url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1/products.json',
22
- method: :get,
23
- status: 200,
24
- body: load_fixture('collection_products'),
25
- extension: false
21
+ 'products',
22
+ url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1/products.json',
23
+ method: :get,
24
+ status: 200,
25
+ body: load_fixture('collection_products'),
26
+ extension: false
26
27
  )
27
28
  assert_equal [632910392, 921728736], collection.products.map(&:id)
28
29
  end
@@ -32,17 +33,17 @@ class CollectionTest < Test::Unit::TestCase
32
33
  ShopifyAPI::Base.activate_session(old_version)
33
34
 
34
35
  fake(
35
- 'collections',
36
- url: 'https://shop2.myshopify.com/admin/api/2019-10/collections/1.json',
37
- method: :get,
38
- status: 200,
39
- body: load_fixture('collection'),
40
- extension: false
36
+ 'collections',
37
+ url: 'https://shop2.myshopify.com/admin/api/2019-10/collections/1.json',
38
+ method: :get,
39
+ status: 200,
40
+ body: load_fixture('collection'),
41
+ extension: false
41
42
  )
42
43
 
43
44
  collection = ShopifyAPI::Collection.find(1)
44
45
 
45
- assert_raises NotImplementedError do
46
+ assert_raises(NotImplementedError) do
46
47
  collection.products
47
48
  end
48
49
  end
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CountableTest < Test::Unit::TestCase
4
5
  def setup
5
6
  super
6
- fake "products/count", :body => '{"count": 16}'
7
+ fake("products/count", body: '{"count": 16}')
7
8
  end
8
9
 
9
10
  def test_count_products
10
11
  count = ShopifyAPI::Product.count
11
- assert_equal 16, count
12
+ assert_equal(16, count)
12
13
  end
13
14
  end
@@ -4,17 +4,17 @@ require 'test_helper'
4
4
  class CurrencyTest < Test::Unit::TestCase
5
5
  def setup
6
6
  super
7
- fake "currencies", method: :get, body: load_fixture('currencies')
7
+ fake("currencies", method: :get, body: load_fixture('currencies'))
8
8
  end
9
9
 
10
10
  context "Currency" do
11
11
  should 'return a list of enabled currencies' do
12
12
  currencies = ShopifyAPI::Currency.all
13
- assert_equal 4, currencies.count
14
- assert_equal %w(AUD EUR GBP HKD), currencies.map(&:currency)
15
- assert_equal [true, true, true, false], currencies.map(&:enabled)
13
+ assert_equal(4, currencies.count)
14
+ assert_equal(%w(AUD EUR GBP HKD), currencies.map(&:currency))
15
+ assert_equal([true, true, true, false], currencies.map(&:enabled))
16
16
  currencies.each do |currency|
17
- assert_equal "2018-10-03T14:44:08-04:00", currency.rate_updated_at
17
+ assert_equal("2018-10-03T14:44:08-04:00", currency.rate_updated_at)
18
18
  end
19
19
  end
20
20
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CustomCollectionTest < Test::Unit::TestCase
4
5
  test "#create should create a custom collection" do
5
- fake "custom_collections", :method => :post, :status => 201, :body => load_fixture('custom_collection')
6
- link = ShopifyAPI::CustomCollection.create(:title => "Macbooks", :image => { :src => "http://example.com/rails_logo.gif" })
7
- assert_equal 1063001463, link.id
6
+ fake("custom_collections", method: :post, status: 201, body: load_fixture('custom_collection'))
7
+ link = ShopifyAPI::CustomCollection.create(title: "Macbooks", image: { src: "http://example.com/rails_logo.gif" })
8
+ assert_equal(1063001463, link.id)
8
9
  end
9
10
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CustomerSavedSearchTest < Test::Unit::TestCase
@@ -7,21 +8,30 @@ class CustomerSavedSearchTest < Test::Unit::TestCase
7
8
  end
8
9
 
9
10
  def test_get_customers_from_customer_saved_search
10
- fake 'customers/search.json?customer_saved_search_id=8899730', :body => load_fixture('customer_saved_search_customers'), :extension => false
11
- assert_equal 1, @customer_saved_search.customers.length
12
- assert_equal 112223902, @customer_saved_search.customers.first.id
11
+ fake(
12
+ 'customers/search.json?customer_saved_search_id=8899730',
13
+ body: load_fixture('customer_saved_search_customers'),
14
+ extension: false
15
+ )
16
+ assert_equal(1, @customer_saved_search.customers.length)
17
+ assert_equal(112223902, @customer_saved_search.customers.first.id)
13
18
  end
14
19
 
15
20
  def test_get_customers_from_customer_saved_search_with_params
16
- fake 'customers/search.json?customer_saved_search_id=8899730&limit=1', :body => load_fixture('customer_saved_search_customers'), :extension => false
17
- customers = @customer_saved_search.customers(:limit => 1)
18
- assert_equal 1, customers.length
19
- assert_equal 112223902, customers.first.id
21
+ fake(
22
+ 'customers/search.json?customer_saved_search_id=8899730&limit=1',
23
+ body: load_fixture('customer_saved_search_customers'),
24
+ extension: false
25
+ )
26
+ customers = @customer_saved_search.customers(limit: 1)
27
+ assert_equal(1, customers.length)
28
+ assert_equal(112223902, customers.first.id)
20
29
  end
21
30
 
22
31
  private
32
+
23
33
  def load_customer_saved_search
24
- fake 'customer_saved_searches/8899730', :body => load_fixture('customer_saved_search')
34
+ fake('customer_saved_searches/8899730', body: load_fixture('customer_saved_search'))
25
35
  @customer_saved_search = ShopifyAPI::CustomerSavedSearch.find(8899730)
26
36
  end
27
37
  end
@@ -1,50 +1,58 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class CustomerTest < Test::Unit::TestCase
4
5
  def setup
5
6
  super
6
7
 
7
- fake 'customers/207119551', body: load_fixture('customers')
8
+ fake('customers/207119551', body: load_fixture('customers'))
8
9
 
9
10
  @customer = ShopifyAPI::Customer.find(207119551)
10
11
  end
11
12
 
12
13
  test "search should get a customers collection" do
13
- fake "customers/search.json?query=Bob+country%3AUnited+States", :extension => false, :body => load_fixture('customers_search')
14
+ fake(
15
+ "customers/search.json?query=Bob+country%3AUnited+States",
16
+ extension: false,
17
+ body: load_fixture('customers_search')
18
+ )
14
19
 
15
20
  results = ShopifyAPI::Customer.search(query: 'Bob country:United States')
16
- assert_equal 'Bob', results.first.first_name
21
+ assert_equal('Bob', results.first.first_name)
17
22
  end
18
23
 
19
24
  test "account_activation_url should create an account activation url" do
20
- fake "customers/207119551/account_activation_url", :method => :post, :body => load_fixture('customers_account_activation_url')
25
+ fake(
26
+ "customers/207119551/account_activation_url",
27
+ method: :post,
28
+ body: load_fixture('customers_account_activation_url')
29
+ )
21
30
 
22
31
  activation_url = "http://apple.myshopify.com/account/activate/207119551/86688abf23572680740b1c062fa37111-1458248616"
23
- assert_equal activation_url, @customer.account_activation_url
32
+ assert_equal(activation_url, @customer.account_activation_url)
24
33
  end
25
34
 
26
35
  test "#send_invite with no params" do
27
36
  customer_invite_fixture = load_fixture('customer_invite')
28
37
  customer_invite = ActiveSupport::JSON.decode(customer_invite_fixture)
29
- fake 'customers/207119551/send_invite', method: :post, body: customer_invite_fixture
38
+ fake('customers/207119551/send_invite', method: :post, body: customer_invite_fixture)
30
39
 
31
40
  customer_invite_response = @customer.send_invite
32
41
 
33
- assert_equal '{"customer_invite":{}}', WebMock.last_request.body
34
- assert_kind_of ShopifyAPI::CustomerInvite, customer_invite_response
35
- assert_equal customer_invite['customer_invite']['to'], customer_invite_response.to
42
+ assert_equal('{"customer_invite":{}}', WebMock.last_request.body)
43
+ assert_kind_of(ShopifyAPI::CustomerInvite, customer_invite_response)
44
+ assert_equal(customer_invite['customer_invite']['to'], customer_invite_response.to)
36
45
  end
37
46
 
38
47
  test "#send_invite with params" do
39
48
  customer_invite_fixture = load_fixture('customer_invite')
40
49
  customer_invite = ActiveSupport::JSON.decode(customer_invite_fixture)
41
- fake 'customers/207119551/send_invite', method: :post, body: customer_invite_fixture
42
-
50
+ fake('customers/207119551/send_invite', method: :post, body: customer_invite_fixture)
43
51
 
44
52
  customer_invite_response = @customer.send_invite(ShopifyAPI::CustomerInvite.new(customer_invite['customer_invite']))
45
53
 
46
- assert_equal customer_invite, ActiveSupport::JSON.decode(WebMock.last_request.body)
47
- assert_kind_of ShopifyAPI::CustomerInvite, customer_invite_response
48
- assert_equal customer_invite['customer_invite']['to'], customer_invite_response.to
54
+ assert_equal(customer_invite, ActiveSupport::JSON.decode(WebMock.last_request.body))
55
+ assert_kind_of(ShopifyAPI::CustomerInvite, customer_invite_response)
56
+ assert_equal(customer_invite['customer_invite']['to'], customer_invite_response.to)
49
57
  end
50
58
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
  require "active_support/log_subscriber/test_helper"
3
4
  require 'json'
@@ -9,18 +10,21 @@ class LogSubscriberTest < Test::Unit::TestCase
9
10
 
10
11
  def setup
11
12
  super
12
- @page = { :page => { :id => 1, :title => 'Shopify API' } }.to_json
13
- @ua_header = "\"User-Agent\"=>\"ShopifyAPI/#{ShopifyAPI::VERSION} ActiveResource/#{ActiveResource::VERSION::STRING} Ruby/#{RUBY_VERSION}\""
13
+ @page = { page: { id: 1, title: 'Shopify API' } }.to_json
14
+ @ua_header = "\"User-Agent\"=>\"ShopifyAPI/#{ShopifyAPI::VERSION} " \
15
+ "ActiveResource/#{ActiveResource::VERSION::STRING} Ruby/#{RUBY_VERSION}\""
14
16
  @request_headers = "Headers: {\"Accept\"=>\"application/json\", " \
15
17
  "#{@ua_header}, \"X-Shopify-Access-Token\"=>\"access_token\"}"
16
18
 
17
19
  ShopifyAPI::Base.clear_session
18
- fake("apis",
20
+ fake(
21
+ "apis",
19
22
  url: "https://app.shopify.com/services/apis.json",
20
23
  method: :get,
21
24
  status: 200,
22
25
  api_version: :stub,
23
- body: load_fixture('apis'))
26
+ body: load_fixture('apis')
27
+ )
24
28
  ShopifyAPI::ApiVersion.fetch_known_versions
25
29
  session = ShopifyAPI::Session.new(
26
30
  domain: "https://this-is-my-test-shop.myshopify.com",
@@ -30,8 +34,8 @@ class LogSubscriberTest < Test::Unit::TestCase
30
34
 
31
35
  ShopifyAPI::Base.activate_session(session)
32
36
 
33
- ActiveResource::LogSubscriber.attach_to :active_resource
34
- ActiveResource::DetailedLogSubscriber.attach_to :active_resource_detailed
37
+ ActiveResource::LogSubscriber.attach_to(:active_resource)
38
+ ActiveResource::DetailedLogSubscriber.attach_to(:active_resource_detailed)
35
39
  end
36
40
 
37
41
  def teardown
@@ -45,7 +49,7 @@ class LogSubscriberTest < Test::Unit::TestCase
45
49
  end
46
50
 
47
51
  test "logging on #find" do
48
- fake "pages/1", :method => :get, :body => @page
52
+ fake("pages/1", method: :get, body: @page)
49
53
 
50
54
  ShopifyAPI::Page.find(1)
51
55
 
@@ -64,9 +68,9 @@ class LogSubscriberTest < Test::Unit::TestCase
64
68
  end
65
69
 
66
70
  test "logging on #find with an error" do
67
- fake "pages/2", :method => :get, :body => nil, :status => 404
71
+ fake("pages/2", method: :get, body: nil, status: 404)
68
72
 
69
- assert_raises ActiveResource::ResourceNotFound do
73
+ assert_raises(ActiveResource::ResourceNotFound) do
70
74
  ShopifyAPI::Page.find(2)
71
75
  end
72
76
 
@@ -103,7 +107,7 @@ class LogSubscriberTest < Test::Unit::TestCase
103
107
 
104
108
  ShopifyAPI::Page.find(1)
105
109
 
106
- assert_equal 1, @logger.logged(:warn).size
110
+ assert_equal(1, @logger.logged(:warn).size)
107
111
 
108
112
  assert_match(
109
113
  %r{\[DEPRECATED\] ShopifyAPI made a call to GET /admin/api/2019-01/pages/1.json},
@@ -125,7 +129,7 @@ class LogSubscriberTest < Test::Unit::TestCase
125
129
 
126
130
  ShopifyAPI::Page.find(1)
127
131
 
128
- assert_equal 1, @logger.logged(:warn).size
132
+ assert_equal(1, @logger.logged(:warn).size)
129
133
 
130
134
  assert_match(
131
135
  %r{\[API Version Warning\] ShopifyAPI made a call to GET /admin/api/2019-01/pages/1.json},