shopify_api 9.2.0 → 9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/ISSUE_TEMPLATE.md +36 -0
  4. data/.github/workflows/build.yml +44 -0
  5. data/.gitignore +0 -1
  6. data/.rubocop.yml +23 -3
  7. data/.rubocop_todo.yml +75 -0
  8. data/CHANGELOG.md +29 -0
  9. data/Gemfile +1 -0
  10. data/Gemfile.lock +153 -0
  11. data/Gemfile_ar51 +1 -1
  12. data/README.md +41 -31
  13. data/RELEASING +10 -6
  14. data/Rakefile +10 -6
  15. data/dev.yml +11 -0
  16. data/docs/graphql.md +1 -1
  17. data/docs/index.md +1 -1
  18. data/lib/active_resource/connection_ext.rb +1 -0
  19. data/lib/active_resource/detailed_log_subscriber.rb +10 -7
  20. data/lib/active_resource/json_errors.rb +8 -2
  21. data/lib/shopify_api/api_access.rb +57 -0
  22. data/lib/shopify_api/api_version.rb +6 -5
  23. data/lib/shopify_api/connection.rb +1 -0
  24. data/lib/shopify_api/countable.rb +3 -2
  25. data/lib/shopify_api/disable_prefix_check.rb +2 -2
  26. data/lib/shopify_api/events.rb +2 -1
  27. data/lib/shopify_api/graphql.rb +8 -6
  28. data/lib/shopify_api/hmac_params.rb +23 -0
  29. data/lib/shopify_api/limits.rb +3 -2
  30. data/lib/shopify_api/message_enricher.rb +11 -9
  31. data/lib/shopify_api/meta.rb +0 -1
  32. data/lib/shopify_api/metafields.rb +5 -4
  33. data/lib/shopify_api/pagination_link_headers.rb +4 -3
  34. data/lib/shopify_api/resources/access_scope.rb +1 -1
  35. data/lib/shopify_api/resources/access_token.rb +1 -0
  36. data/lib/shopify_api/resources/address.rb +1 -0
  37. data/lib/shopify_api/resources/announcement.rb +2 -1
  38. data/lib/shopify_api/resources/application_charge.rb +1 -0
  39. data/lib/shopify_api/resources/application_credit.rb +1 -0
  40. data/lib/shopify_api/resources/article.rb +3 -2
  41. data/lib/shopify_api/resources/asset.rb +6 -5
  42. data/lib/shopify_api/resources/assigned_fulfillment_order.rb +1 -1
  43. data/lib/shopify_api/resources/base.rb +11 -6
  44. data/lib/shopify_api/resources/billing_address.rb +1 -0
  45. data/lib/shopify_api/resources/blog.rb +2 -1
  46. data/lib/shopify_api/resources/carrier_service.rb +1 -0
  47. data/lib/shopify_api/resources/cart.rb +2 -1
  48. data/lib/shopify_api/resources/collect.rb +1 -0
  49. data/lib/shopify_api/resources/collection_listing.rb +1 -0
  50. data/lib/shopify_api/resources/comment.rb +20 -5
  51. data/lib/shopify_api/resources/country.rb +1 -0
  52. data/lib/shopify_api/resources/custom_collection.rb +4 -3
  53. data/lib/shopify_api/resources/customer.rb +2 -1
  54. data/lib/shopify_api/resources/customer_group.rb +1 -0
  55. data/lib/shopify_api/resources/customer_invite.rb +1 -0
  56. data/lib/shopify_api/resources/customer_saved_search.rb +2 -1
  57. data/lib/shopify_api/resources/discount_code.rb +1 -0
  58. data/lib/shopify_api/resources/discount_code_batch.rb +4 -2
  59. data/lib/shopify_api/resources/draft_order.rb +1 -0
  60. data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
  61. data/lib/shopify_api/resources/event.rb +1 -0
  62. data/lib/shopify_api/resources/fulfillment.rb +12 -3
  63. data/lib/shopify_api/resources/fulfillment_event.rb +1 -0
  64. data/lib/shopify_api/resources/fulfillment_order.rb +30 -16
  65. data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +1 -0
  66. data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
  67. data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
  68. data/lib/shopify_api/resources/fulfillment_v2.rb +3 -2
  69. data/lib/shopify_api/resources/gift_card.rb +1 -0
  70. data/lib/shopify_api/resources/image.rb +2 -1
  71. data/lib/shopify_api/resources/inventory_level.rb +2 -3
  72. data/lib/shopify_api/resources/line_item.rb +4 -3
  73. data/lib/shopify_api/resources/location.rb +1 -1
  74. data/lib/shopify_api/resources/marketing_event.rb +1 -0
  75. data/lib/shopify_api/resources/metafield.rb +1 -0
  76. data/lib/shopify_api/resources/note_attribute.rb +1 -0
  77. data/lib/shopify_api/resources/option.rb +1 -0
  78. data/lib/shopify_api/resources/order.rb +2 -1
  79. data/lib/shopify_api/resources/order_risk.rb +1 -0
  80. data/lib/shopify_api/resources/page.rb +1 -0
  81. data/lib/shopify_api/resources/payment_details.rb +1 -0
  82. data/lib/shopify_api/resources/policy.rb +1 -0
  83. data/lib/shopify_api/resources/price_rule.rb +1 -1
  84. data/lib/shopify_api/resources/product.rb +14 -11
  85. data/lib/shopify_api/resources/product_listing.rb +1 -0
  86. data/lib/shopify_api/resources/province.rb +1 -0
  87. data/lib/shopify_api/resources/receipt.rb +1 -0
  88. data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
  89. data/lib/shopify_api/resources/redirect.rb +1 -0
  90. data/lib/shopify_api/resources/refund.rb +2 -1
  91. data/lib/shopify_api/resources/report.rb +1 -0
  92. data/lib/shopify_api/resources/resource_feedback.rb +1 -1
  93. data/lib/shopify_api/resources/rule.rb +1 -0
  94. data/lib/shopify_api/resources/script_tag.rb +1 -0
  95. data/lib/shopify_api/resources/shipping_address.rb +1 -0
  96. data/lib/shopify_api/resources/shipping_line.rb +1 -0
  97. data/lib/shopify_api/resources/shipping_zone.rb +1 -0
  98. data/lib/shopify_api/resources/shop.rb +2 -1
  99. data/lib/shopify_api/resources/smart_collection.rb +2 -2
  100. data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
  101. data/lib/shopify_api/resources/tax_line.rb +1 -0
  102. data/lib/shopify_api/resources/tax_service.rb +1 -0
  103. data/lib/shopify_api/resources/theme.rb +1 -0
  104. data/lib/shopify_api/resources/transaction.rb +1 -0
  105. data/lib/shopify_api/resources/usage_charge.rb +1 -0
  106. data/lib/shopify_api/resources/user.rb +1 -0
  107. data/lib/shopify_api/resources/variant.rb +16 -18
  108. data/lib/shopify_api/resources/webhook.rb +1 -0
  109. data/lib/shopify_api/resources.rb +1 -0
  110. data/lib/shopify_api/session.rb +29 -19
  111. data/lib/shopify_api/version.rb +2 -1
  112. data/lib/shopify_api.rb +9 -1
  113. data/lib/verify_docs.rb +1 -0
  114. data/service.yml +2 -5
  115. data/shopify_api.gemspec +12 -5
  116. data/test/access_token_test.rb +6 -5
  117. data/test/active_resource/json_errors_test.rb +6 -6
  118. data/test/api_access_test.rb +153 -0
  119. data/test/api_version_test.rb +3 -3
  120. data/test/application_charge_test.rb +30 -27
  121. data/test/application_credit_test.rb +10 -9
  122. data/test/article_test.rb +34 -35
  123. data/test/asset_test.rb +14 -6
  124. data/test/assigned_fulfillment_order_test.rb +5 -4
  125. data/test/base_test.rb +55 -56
  126. data/test/blog_test.rb +4 -3
  127. data/test/carrier_service_test.rb +7 -6
  128. data/test/cart_test.rb +2 -1
  129. data/test/collect_test.rb +4 -3
  130. data/test/collection_listing_test.rb +21 -16
  131. data/test/collection_publication_test.rb +8 -8
  132. data/test/collection_test.rb +20 -19
  133. data/test/countable_test.rb +3 -2
  134. data/test/currency_test.rb +5 -5
  135. data/test/custom_collection_test.rb +4 -3
  136. data/test/customer_saved_search_test.rb +18 -8
  137. data/test/customer_test.rb +22 -14
  138. data/test/detailed_log_subscriber_test.rb +16 -12
  139. data/test/discount_code_batch_test.rb +11 -10
  140. data/test/discount_code_test.rb +21 -15
  141. data/test/draft_order_test.rb +68 -52
  142. data/test/fixtures/assigned_fulfillment_orders.json +2 -0
  143. data/test/fixtures/fulfillment_order.json +1 -0
  144. data/test/fixtures/fulfillment_orders.json +2 -0
  145. data/test/fulfillment_event_test.rb +31 -26
  146. data/test/fulfillment_order_test.rb +217 -149
  147. data/test/fulfillment_order_test_helper.rb +1 -0
  148. data/test/fulfillment_request_test.rb +10 -8
  149. data/test/fulfillment_service_test.rb +13 -12
  150. data/test/fulfillment_test.rb +81 -66
  151. data/test/fulfillment_v2_test.rb +16 -12
  152. data/test/gift_card_test.rb +6 -4
  153. data/test/graphql_test.rb +27 -27
  154. data/test/hmac_params_test.rb +25 -0
  155. data/test/image_test.rb +19 -17
  156. data/test/inventory_level_test.rb +24 -15
  157. data/test/lib/webmock_extensions/last_request.rb +1 -1
  158. data/test/limits_test.rb +2 -1
  159. data/test/location_test.rb +2 -1
  160. data/test/marketing_event_test.rb +20 -20
  161. data/test/message_enricher_test.rb +6 -6
  162. data/test/meta_test.rb +9 -11
  163. data/test/metafield_test.rb +30 -20
  164. data/test/order_risk_test.rb +17 -16
  165. data/test/order_test.rb +43 -28
  166. data/test/pagination_test.rb +89 -56
  167. data/test/policy_test.rb +6 -5
  168. data/test/price_rule_test.rb +20 -15
  169. data/test/product_listing_test.rb +20 -20
  170. data/test/product_publication_test.rb +8 -8
  171. data/test/product_test.rb +44 -32
  172. data/test/publication_test.rb +3 -3
  173. data/test/recurring_application_charge_test.rb +104 -42
  174. data/test/redirect_test.rb +4 -3
  175. data/test/refund_test.rb +22 -17
  176. data/test/report_test.rb +12 -10
  177. data/test/resource_feedback_test.rb +14 -13
  178. data/test/script_tag_test.rb +10 -9
  179. data/test/session_test.rb +159 -48
  180. data/test/shipping_zone_test.rb +4 -3
  181. data/test/shop_test.rb +47 -33
  182. data/test/smart_collection_test.rb +5 -4
  183. data/test/storefront_access_token_test.rb +13 -15
  184. data/test/tax_service_test.rb +7 -4
  185. data/test/tender_transaction_test.rb +3 -3
  186. data/test/test_helper.rb +13 -11
  187. data/test/transaction_test.rb +4 -3
  188. data/test/usage_charge_test.rb +12 -8
  189. data/test/user_test.rb +4 -3
  190. data/test/variant_test.rb +23 -54
  191. data/test/webhook_test.rb +10 -7
  192. metadata +34 -12
  193. data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1027
  194. data/.travis.yml +0 -28
@@ -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
- "#{@ua_header}, \"X-Shopify-Access-Token\"=>\"access_token\"}"
17
+ "#{@ua_header}, \"X-Shopify-Access-Token\"=>\"[FILTERED]\"}"
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},
@@ -4,30 +4,31 @@ require 'test_helper'
4
4
  class DiscountCodeBatchTest < Test::Unit::TestCase
5
5
  def setup
6
6
  super
7
- fake 'price_rules/102586120/batch/989355119', body: load_fixture('discount_code_batch')
7
+ fake('price_rules/102586120/batch/989355119', body: load_fixture('discount_code_batch'))
8
8
  end
9
9
 
10
10
  def test_get_batch
11
- batch = ShopifyAPI::DiscountCodeBatch.find 989355119, params: { price_rule_id: 102586120 }
11
+ batch = ShopifyAPI::DiscountCodeBatch.find(989355119, params: { price_rule_id: 102586120 })
12
12
 
13
- assert_equal 989355119, batch.id
13
+ assert_equal(989355119, batch.id)
14
14
  end
15
15
 
16
16
  def test_get_batch_discount_codes
17
- fake 'price_rules/102586120/batch/989355119/discount_codes',
17
+ fake(
18
+ 'price_rules/102586120/batch/989355119/discount_codes',
18
19
  method: :get,
19
20
  status: 200,
20
21
  body: load_fixture('discount_code_batch_discount_codes')
21
-
22
- batch = ShopifyAPI::DiscountCodeBatch.find 989355119, params: { price_rule_id: 102586120 }
22
+ )
23
+ batch = ShopifyAPI::DiscountCodeBatch.find(989355119, params: { price_rule_id: 102586120 })
23
24
  discount_code_job = batch.discount_code_job
24
25
 
25
- assert_equal 3, discount_code_job.count
26
- assert discount_code_job[2].errors.present?
26
+ assert_equal(3, discount_code_job.count)
27
+ assert(discount_code_job[2].errors.present?)
27
28
  end
28
29
 
29
30
  def test_create_batch
30
- fake 'price_rules/102586120/batch', method: :post, status: 201, body: load_fixture('discount_code_batch')
31
+ fake('price_rules/102586120/batch', method: :post, status: 201, body: load_fixture('discount_code_batch'))
31
32
  batch = ShopifyAPI::DiscountCodeBatch.new
32
33
  batch.prefix_options[:price_rule_id] = 102586120
33
34
  discount_codes = [{ "code": "SUMMER1" }, { "code": "SUMMER2" }, { "code": "SUMMER3" }]
@@ -35,6 +36,6 @@ class DiscountCodeBatchTest < Test::Unit::TestCase
35
36
  batch.save
36
37
 
37
38
  expected_body = { discount_codes: discount_codes }.to_json
38
- assert_equal expected_body, WebMock.last_request.body
39
+ assert_equal(expected_body, WebMock.last_request.body)
39
40
  end
40
41
  end
@@ -1,36 +1,37 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class DiscountCodeTest < Test::Unit::TestCase
4
5
  def setup
5
6
  super
6
- fake 'price_rules/102586120/discount_codes/1002091923', body: load_fixture('discount_code')
7
+ fake('price_rules/102586120/discount_codes/1002091923', body: load_fixture('discount_code'))
7
8
 
8
- @discount_code = ShopifyAPI::DiscountCode.find(1002091923, params: {price_rule_id: 102586120})
9
+ @discount_code = ShopifyAPI::DiscountCode.find(1002091923, params: { price_rule_id: 102586120 })
9
10
  end
10
11
 
11
12
  def test_get_discount_code
12
- fake 'price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_code')
13
- discount_code = ShopifyAPI::DiscountCode.find 1002091923, params: { price_rule_id: 102586120 }
13
+ fake('price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_code'))
14
+ discount_code = ShopifyAPI::DiscountCode.find(1002091923, params: { price_rule_id: 102586120 })
14
15
 
15
- assert_equal 1002091923, discount_code.id
16
+ assert_equal(1002091923, discount_code.id)
16
17
  end
17
18
 
18
19
  def test_get_all_discount_codes
19
- fake 'price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_codes')
20
- discount_codes = ShopifyAPI::DiscountCode.all params: { price_rule_id: 102586120 }
20
+ fake('price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_codes'))
21
+ discount_codes = ShopifyAPI::DiscountCode.all(params: { price_rule_id: 102586120 })
21
22
 
22
- assert_equal 1, discount_codes.length
23
- assert_equal 1002091923, discount_codes.first.id
23
+ assert_equal(1, discount_codes.length)
24
+ assert_equal(1002091923, discount_codes.first.id)
24
25
  end
25
26
 
26
27
  def test_create_discount_code
27
- fake 'price_rules/102586120/discount_codes', method: :post, status: 201, body: load_fixture('discount_code')
28
+ fake('price_rules/102586120/discount_codes', method: :post, status: 201, body: load_fixture('discount_code'))
28
29
  discount_code = ShopifyAPI::DiscountCode.new
29
30
  discount_code.prefix_options[:price_rule_id] = 102586120
30
31
  discount_code.code = "SUMMERSALE10"
31
32
  discount_code.save
32
33
 
33
- assert_equal '{"discount_code":{"code":"SUMMERSALE10"}}', WebMock.last_request.body
34
+ assert_equal('{"discount_code":{"code":"SUMMERSALE10"}}', WebMock.last_request.body)
34
35
  end
35
36
 
36
37
  def test_update_discount_code
@@ -38,16 +39,21 @@ class DiscountCodeTest < Test::Unit::TestCase
38
39
  discount_code_response['discount_code']['code'] = "WINTERSALE50"
39
40
  @discount_code.code = "WINTERSALE50"
40
41
 
41
- fake 'price_rules/102586120/discount_codes/1002091923', method: :put, status: 200, body: ActiveSupport::JSON.encode(discount_code_response)
42
+ fake(
43
+ 'price_rules/102586120/discount_codes/1002091923',
44
+ method: :put,
45
+ status: 200,
46
+ body: ActiveSupport::JSON.encode(discount_code_response)
47
+ )
42
48
 
43
49
  @discount_code.save
44
50
 
45
- assert_equal discount_code_response['discount_code']['code'], @discount_code.code
51
+ assert_equal(discount_code_response['discount_code']['code'], @discount_code.code)
46
52
  end
47
53
 
48
54
  def test_delete_discount_code
49
- fake 'price_rules/102586120/discount_codes/1002091923', method: :delete, body: 'destroyed'
55
+ fake('price_rules/102586120/discount_codes/1002091923', method: :delete, body: 'destroyed')
50
56
 
51
- assert @discount_code.destroy
57
+ assert(@discount_code.destroy)
52
58
  end
53
59
  end