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 PaginationTest < Test::Unit::TestCase
@@ -9,14 +10,16 @@ class PaginationTest < Test::Unit::TestCase
9
10
  @next_page_info = "eyJkaXJlY3Rpb24iOiJuZXh0IiwibGFzdF9pZCI6NDQwMDg5NDIzLCJsYXN0X3ZhbHVlIjoiNDQwMDg5NDIzIn0%3D"
10
11
  @previous_page_info = "eyJsYXN0X2lkIjoxMDg4MjgzMDksImxhc3RfdmFsdWUiOiIxMDg4MjgzMDkiLCJkaXJlY3Rpb24iOiJuZXh0In0%3D"
11
12
 
12
- @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@next_page_info}>; rel=\"next\""
13
- @previous_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@previous_page_info}>; rel=\"previous\""
13
+ @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
14
+ "orders.json?page_info=#{@next_page_info}>; rel=\"next\""
15
+ @previous_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
16
+ "orders.json?page_info=#{@previous_page_info}>; rel=\"previous\""
14
17
  end
15
18
 
16
19
  test "navigates using next and previous link headers with no original params" do
17
- link_header ="#{@previous_link_header}, #{@next_link_header}"
20
+ link_header = "#{@previous_link_header}, #{@next_link_header}"
18
21
 
19
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => link_header
22
+ fake('orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: link_header)
20
23
  orders = ShopifyAPI::Order.all
21
24
 
22
25
  fake(
@@ -27,7 +30,7 @@ class PaginationTest < Test::Unit::TestCase
27
30
  body: load_fixture('orders')
28
31
  )
29
32
  next_page = orders.fetch_next_page
30
- assert_equal 450789469, next_page.first.id
33
+ assert_equal(450789469, next_page.first.id)
31
34
 
32
35
  fake(
33
36
  'orders',
@@ -38,12 +41,13 @@ class PaginationTest < Test::Unit::TestCase
38
41
  )
39
42
 
40
43
  previous_page = orders.fetch_previous_page
41
- assert_equal 1122334455, previous_page.first.id
44
+ assert_equal(1122334455, previous_page.first.id)
42
45
  end
43
46
 
44
47
  test "uses all passed in querystring parameters" do
45
48
  params = "page_info=#{@next_page_info}&limit=50&fields=#{CGI.escape('id,created_at')}"
46
- @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?#{params}>; rel=\"next\""
49
+ @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
50
+ "orders.json?#{params}>; rel=\"next\""
47
51
  fake(
48
52
  'orders',
49
53
  method: :get,
@@ -60,100 +64,127 @@ class PaginationTest < Test::Unit::TestCase
60
64
  method: :get,
61
65
  status: 200,
62
66
  api_version: @version,
63
- url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?fields=id%2Ccreated_at&limit=50&page_info=#{@next_page_info}",
67
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
68
+ "orders.json?fields=id%2Ccreated_at&limit=50&page_info=#{@next_page_info}",
64
69
  body: load_fixture('orders')
65
70
  )
66
71
  next_page = orders.fetch_next_page
67
- assert_equal 450789469, next_page.first.id
72
+ assert_equal(450789469, next_page.first.id)
68
73
  end
69
74
 
70
75
  test "returns empty next page if just the previous page is present" do
71
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
76
+ fake(
77
+ 'orders', method: :get, status: 200, api_version: @version,
78
+ body: load_fixture('orders'), link: @previous_link_header
79
+ )
72
80
  orders = ShopifyAPI::Order.all
73
81
 
74
82
  next_page = orders.fetch_next_page
75
- assert_empty next_page
83
+ assert_empty(next_page)
76
84
  end
77
85
 
78
86
  test "returns an empty previous page if just the next page is present" do
79
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
87
+ fake(
88
+ 'orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: @next_link_header
89
+ )
80
90
  orders = ShopifyAPI::Order.all
81
91
 
82
92
  next_page = orders.fetch_previous_page
83
- assert_empty next_page
93
+ assert_empty(next_page)
84
94
  end
85
95
 
86
96
  test "#next_page? returns true if next page is present" do
87
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
97
+ fake(
98
+ 'orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: @next_link_header
99
+ )
88
100
  orders = ShopifyAPI::Order.all
89
101
 
90
- assert orders.next_page?
102
+ assert(orders.next_page?)
91
103
  end
92
104
 
93
105
  test "#next_page? returns false if next page is not present" do
94
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
106
+ fake(
107
+ 'orders', method: :get, status: 200, api_version: @version,
108
+ body: load_fixture('orders'), link: @previous_link_header
109
+ )
95
110
  orders = ShopifyAPI::Order.all
96
111
 
97
- refute orders.next_page?
112
+ refute(orders.next_page?)
98
113
  end
99
114
 
100
115
  test "#next_page_info returns next_page_info if next page is present" do
101
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
116
+ fake(
117
+ 'orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: @next_link_header
118
+ )
102
119
  orders = ShopifyAPI::Order.all
103
120
 
104
- assert_equal @next_page_info, orders.next_page_info
121
+ assert_equal(@next_page_info, orders.next_page_info)
105
122
  end
106
123
 
107
124
  test "#next_page_info returns nil if next page is not present" do
108
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
125
+ fake(
126
+ 'orders', method: :get, status: 200, api_version: @version,
127
+ body: load_fixture('orders'), link: @previous_link_header
128
+ )
109
129
  orders = ShopifyAPI::Order.all
110
130
 
111
- assert_nil orders.next_page_info
131
+ assert_nil(orders.next_page_info)
112
132
  end
113
133
 
114
134
  test "#previous_page? returns true if previous page is present" do
115
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
135
+ fake(
136
+ 'orders', method: :get, status: 200, api_version: @version,
137
+ body: load_fixture('orders'), link: @previous_link_header
138
+ )
116
139
  orders = ShopifyAPI::Order.all
117
140
 
118
- assert orders.previous_page?
141
+ assert(orders.previous_page?)
119
142
  end
120
143
 
121
144
  test "#previous_page? returns false if next page is not present" do
122
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
145
+ fake(
146
+ 'orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: @next_link_header
147
+ )
123
148
  orders = ShopifyAPI::Order.all
124
149
 
125
- refute orders.previous_page?
150
+ refute(orders.previous_page?)
126
151
  end
127
152
 
128
153
  test "#previous_page_info returns previous_page_info if next page is present" do
129
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @previous_link_header
154
+ fake(
155
+ 'orders', method: :get, status: 200, api_version: @version,
156
+ body: load_fixture('orders'), link: @previous_link_header
157
+ )
130
158
  orders = ShopifyAPI::Order.all
131
159
 
132
- assert_equal @previous_page_info, orders.previous_page_info
160
+ assert_equal(@previous_page_info, orders.previous_page_info)
133
161
  end
134
162
 
135
163
  test "#previous_page_info returns nil if next page is not present" do
136
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => @next_link_header
164
+ fake(
165
+ 'orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: @next_link_header
166
+ )
137
167
  orders = ShopifyAPI::Order.all
138
168
 
139
- assert_nil orders.previous_page_info
169
+ assert_nil(orders.previous_page_info)
140
170
  end
141
171
 
142
172
  test "pagination handles no link headers" do
143
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders')
173
+ fake('orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'))
144
174
  orders = ShopifyAPI::Order.all
145
175
 
146
- refute orders.next_page?
147
- refute orders.previous_page?
148
- assert_empty orders.fetch_next_page
149
- assert_empty orders.fetch_previous_page
176
+ refute(orders.next_page?)
177
+ refute(orders.previous_page?)
178
+ assert_empty(orders.fetch_next_page)
179
+ assert_empty(orders.fetch_previous_page)
150
180
  end
151
181
 
152
182
  test "raises on invalid pagination links" do
153
- link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?page_info=#{@next_page_info}>;"
154
- fake 'orders', :method => :get, :status => 200, api_version: @version, :body => load_fixture('orders'), :link => link_header
183
+ link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
184
+ "orders.json?page_info=#{@next_page_info}>;"
185
+ fake('orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: link_header)
155
186
 
156
- assert_raises ShopifyAPI::InvalidPaginationLinksError do
187
+ assert_raises(ShopifyAPI::InvalidPaginationLinksError) do
157
188
  ShopifyAPI::Order.all
158
189
  end
159
190
  end
@@ -162,10 +193,10 @@ class PaginationTest < Test::Unit::TestCase
162
193
  version = ShopifyAPI::ApiVersion.find_version('2019-04')
163
194
  ShopifyAPI::Base.api_version = version.to_s
164
195
 
165
- fake 'orders', :method => :get, :status => 200, api_version: version, :body => load_fixture('orders')
196
+ fake('orders', method: :get, status: 200, api_version: version, body: load_fixture('orders'))
166
197
  orders = ShopifyAPI::Order.all
167
198
 
168
- assert_raises NotImplementedError do
199
+ assert_raises(NotImplementedError) do
169
200
  orders.fetch_next_page
170
201
  end
171
202
  end
@@ -174,10 +205,10 @@ class PaginationTest < Test::Unit::TestCase
174
205
  version = ShopifyAPI::ApiVersion.find_version('2019-07')
175
206
  ShopifyAPI::Base.api_version = version.to_s
176
207
 
177
- fake 'orders', :method => :get, :status => 200, api_version: version, :body => load_fixture('orders')
208
+ fake('orders', method: :get, status: 200, api_version: version, body: load_fixture('orders'))
178
209
  orders = ShopifyAPI::Order.all
179
210
 
180
- assert_raises NotImplementedError do
211
+ assert_raises(NotImplementedError) do
181
212
  orders.fetch_next_page
182
213
  end
183
214
  end
@@ -186,21 +217,22 @@ class PaginationTest < Test::Unit::TestCase
186
217
  version = ShopifyAPI::ApiVersion.find_version('2019-07')
187
218
  ShopifyAPI::Base.api_version = version.to_s
188
219
 
189
- fake 'events', :method => :get, :status => 200, api_version: version, :body => load_fixture('events')
220
+ fake('events', method: :get, status: 200, api_version: version, body: load_fixture('events'))
190
221
  events = ShopifyAPI::Event.all
191
222
 
192
- assert_empty events.fetch_next_page
193
- assert_empty events.fetch_previous_page
223
+ assert_empty(events.fetch_next_page)
224
+ assert_empty(events.fetch_previous_page)
194
225
  end
195
226
 
196
227
  test "does not raise on the unstable version" do
197
228
  version = ShopifyAPI::ApiVersion.find_version('unstable')
198
229
  ShopifyAPI::Base.api_version = version.to_s
199
- @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/unstable/orders.json?page_info=#{@next_page_info}>; rel=\"next\""
230
+ @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/unstable/" \
231
+ "orders.json?page_info=#{@next_page_info}>; rel=\"next\""
200
232
 
201
- link_header ="#{@previous_link_header}, #{@next_link_header}"
233
+ link_header = "#{@previous_link_header}, #{@next_link_header}"
202
234
 
203
- fake 'orders', :method => :get, :status => 200, api_version: version, :body => load_fixture('orders'), :link => link_header
235
+ fake('orders', method: :get, status: 200, api_version: version, body: load_fixture('orders'), link: link_header)
204
236
  orders = ShopifyAPI::Order.all
205
237
 
206
238
  fake(
@@ -212,7 +244,7 @@ class PaginationTest < Test::Unit::TestCase
212
244
  )
213
245
  assert_nothing_raised do
214
246
  next_page = orders.fetch_next_page
215
- assert_equal 450789469, next_page.first.id
247
+ assert_equal(450789469, next_page.first.id)
216
248
  end
217
249
  end
218
250
 
@@ -225,9 +257,10 @@ class PaginationTest < Test::Unit::TestCase
225
257
  api_version: @version,
226
258
  url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?limit=5",
227
259
  body: load_fixture('orders'),
228
- link: "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?#{first_request_params}>; rel=\"next\""
260
+ link: "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
261
+ "orders.json?#{first_request_params}>; rel=\"next\""
229
262
  )
230
- orders = ShopifyAPI::Order.where(limit: 5)
263
+ ShopifyAPI::Order.where(limit: 5)
231
264
 
232
265
  second_request_params = "page_info=#{@next_page_info}&limit=5"
233
266
  fake(
@@ -237,21 +270,21 @@ class PaginationTest < Test::Unit::TestCase
237
270
  api_version: @version,
238
271
  url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?limit=10",
239
272
  body: load_fixture('orders'),
240
- link: "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?#{second_request_params}>; rel=\"next\""
273
+ link: "<https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
274
+ "orders.json?#{second_request_params}>; rel=\"next\""
241
275
  )
242
-
243
- orders2 = ShopifyAPI::Order.where(limit: 10)
276
+ orders = ShopifyAPI::Order.where(limit: 10)
244
277
 
245
278
  fake(
246
279
  'orders',
247
280
  method: :get,
248
281
  status: 200,
249
282
  api_version: @version,
250
- url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/orders.json?limit=5&page_info=#{@next_page_info}",
283
+ url: "https://this-is-my-test-shop.myshopify.com/admin/api/2019-10/" \
284
+ "orders.json?limit=5&page_info=#{@next_page_info}",
251
285
  body: load_fixture('orders')
252
286
  )
253
287
  next_page = orders.fetch_next_page
254
- assert_equal 450789469, next_page.first.id
288
+ assert_equal(450789469, next_page.first.id)
255
289
  end
256
-
257
290
  end
data/test/policy_test.rb CHANGED
@@ -1,19 +1,20 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class PolicyTest < Test::Unit::TestCase
4
5
  def setup
5
6
  super
6
- fake 'shop'
7
+ fake('shop')
7
8
  end
8
9
 
9
10
  def test_getting_the_list_of_policies
10
- fake 'policies'
11
+ fake('policies')
11
12
 
12
13
  policies = ShopifyAPI::Policy.all
13
- assert_equal 1, policies.length
14
+ assert_equal(1, policies.length)
14
15
 
15
16
  policy = policies.first
16
- assert_equal 'Privacy Policy', policy.title
17
- assert_equal 'Your privacy is important to us', policy.body
17
+ assert_equal('Privacy Policy', policy.title)
18
+ assert_equal('Your privacy is important to us', policy.body)
18
19
  end
19
20
  end
@@ -1,37 +1,38 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class PriceRuleTest < Test::Unit::TestCase
4
5
  def setup
5
6
  super
6
- fake 'price_rules/102586120', body: load_fixture('price_rule')
7
+ fake('price_rules/102586120', body: load_fixture('price_rule'))
7
8
 
8
9
  @price_rule = ShopifyAPI::PriceRule.find(102586120)
9
10
  end
10
11
 
11
12
  def test_get_price_rule
12
- fake 'price_rules/102586120', method: :get, status: 200, body: load_fixture('price_rule')
13
+ fake('price_rules/102586120', method: :get, status: 200, body: load_fixture('price_rule'))
13
14
  price_rule = ShopifyAPI::PriceRule.find(102586120)
14
15
 
15
- assert_equal 102586120, price_rule.id
16
+ assert_equal(102586120, price_rule.id)
16
17
  end
17
18
 
18
19
  def test_get_all_price_rules
19
- fake 'price_rules', method: :get, status: 200, body: load_fixture('price_rules')
20
+ fake('price_rules', method: :get, status: 200, body: load_fixture('price_rules'))
20
21
  price_rules = ShopifyAPI::PriceRule.all
21
22
 
22
- assert_equal 1, price_rules.length
23
- assert_equal 102586120, price_rules.first.id
23
+ assert_equal(1, price_rules.length)
24
+ assert_equal(102586120, price_rules.first.id)
24
25
  end
25
26
 
26
27
  def test_get_all_discount_codes_for_a_price_rule
27
- fake 'price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_codes')
28
+ fake('price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_codes'))
28
29
  price_rule = ShopifyAPI::PriceRule.find(102586120)
29
30
 
30
- assert_equal "SUMMERSALE10", price_rule.discount_codes.first.code
31
+ assert_equal("SUMMERSALE10", price_rule.discount_codes.first.code)
31
32
  end
32
33
 
33
34
  def test_create_price_rule
34
- fake 'price_rules', method: :post, status: 201, body: load_fixture('price_rule')
35
+ fake('price_rules', method: :post, status: 201, body: load_fixture('price_rule'))
35
36
 
36
37
  price_rule = ShopifyAPI::PriceRule.create(
37
38
  target_type: "line_item",
@@ -42,24 +43,28 @@ class PriceRuleTest < Test::Unit::TestCase
42
43
  starts_at: "2017-01-19T00:00:00Z"
43
44
  )
44
45
 
45
- assert_equal '{"price_rule":{"target_type":"line_item","allocation_method":"across","value_type":"fixed_amount","value":-10.0,"customer_selection":"all","starts_at":"2017-01-19T00:00:00Z"}}', WebMock.last_request.body
46
- assert_equal -10, price_rule.value
46
+ assert_equal(
47
+ '{"price_rule":{"target_type":"line_item","allocation_method":"across","value_type":"fixed_amount",' \
48
+ '"value":-10.0,"customer_selection":"all","starts_at":"2017-01-19T00:00:00Z"}}',
49
+ WebMock.last_request.body
50
+ )
51
+ assert_equal(-10, price_rule.value)
47
52
  end
48
53
 
49
54
  def test_update_price_rule
50
55
  price_rule_response = ActiveSupport::JSON.decode(load_fixture('price_rule'))
51
56
  price_rule_response['price_rule']['value'] = -50.0
52
57
  @price_rule.value = -50.0
53
- fake 'price_rules/102586120', method: :put, status: 200, body: ActiveSupport::JSON.encode(price_rule_response)
58
+ fake('price_rules/102586120', method: :put, status: 200, body: ActiveSupport::JSON.encode(price_rule_response))
54
59
 
55
60
  @price_rule.save
56
61
 
57
- assert_equal price_rule_response['price_rule']['value'], @price_rule.value
62
+ assert_equal(price_rule_response['price_rule']['value'], @price_rule.value)
58
63
  end
59
64
 
60
65
  def test_delete_price_rule
61
- fake 'price_rules/102586120', method: :delete, body: 'destroyed'
66
+ fake('price_rules/102586120', method: :delete, body: 'destroyed')
62
67
 
63
- assert @price_rule.destroy
68
+ assert(@price_rule.destroy)
64
69
  end
65
70
  end
@@ -1,41 +1,41 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class ProductListingTest < Test::Unit::TestCase
4
-
5
5
  def test_get_product_listings
6
- fake "product_listings", method: :get, status: 201, body: load_fixture('product_listings')
6
+ fake("product_listings", method: :get, status: 201, body: load_fixture('product_listings'))
7
7
 
8
8
  product_listings = ShopifyAPI::ProductListing.find(:all)
9
- assert_equal 2, product_listings.count
10
- assert_equal 2, product_listings.first.product_id
11
- assert_equal 1, product_listings.last.product_id
12
- assert_equal 'Synergistic Silk Chair', product_listings.first.title
13
- assert_equal 'Rustic Copper Bottle', product_listings.last.title
9
+ assert_equal(2, product_listings.count)
10
+ assert_equal(2, product_listings.first.product_id)
11
+ assert_equal(1, product_listings.last.product_id)
12
+ assert_equal('Synergistic Silk Chair', product_listings.first.title)
13
+ assert_equal('Rustic Copper Bottle', product_listings.last.title)
14
14
  end
15
15
 
16
16
  def test_get_product_listing
17
- fake "product_listings/2", method: :get, status: 201, body: load_fixture('product_listing')
17
+ fake("product_listings/2", method: :get, status: 201, body: load_fixture('product_listing'))
18
18
 
19
19
  product_listing = ShopifyAPI::ProductListing.find(2)
20
- assert_equal 'Synergistic Silk Chair', product_listing.title
20
+ assert_equal('Synergistic Silk Chair', product_listing.title)
21
21
  end
22
22
 
23
23
  def test_reload_product_listing
24
- fake "product_listings/2", method: :get, status: 201, body: load_fixture('product_listing')
24
+ fake("product_listings/2", method: :get, status: 201, body: load_fixture('product_listing'))
25
25
 
26
26
  product_listing = ShopifyAPI::ProductListing.new(product_id: 2)
27
27
  product_listing.reload
28
28
 
29
- assert_equal 'Synergistic Silk Chair', product_listing.title
29
+ assert_equal('Synergistic Silk Chair', product_listing.title)
30
30
  end
31
31
 
32
32
  def test_get_product_listing_product_ids
33
- fake "product_listings/product_ids", method: :get, status: 201, body: load_fixture('product_listing_product_ids')
33
+ fake("product_listings/product_ids", method: :get, status: 201, body: load_fixture('product_listing_product_ids'))
34
34
 
35
35
  product_ids = ShopifyAPI::ProductListing.product_ids
36
- assert_equal 2, product_ids.count
37
- assert_equal 4, product_ids.first
38
- assert_equal 3, product_ids.last
36
+ assert_equal(2, product_ids.count)
37
+ assert_equal(4, product_ids.first)
38
+ assert_equal(3, product_ids.last)
39
39
  end
40
40
 
41
41
  def test_get_product_listing_product_ids_multi_page_with_cursor
@@ -58,8 +58,8 @@ class ProductListingTest < Test::Unit::TestCase
58
58
  )
59
59
 
60
60
  product_ids = ShopifyAPI::ProductListing.product_ids
61
- assert_equal [4, 3], product_ids
62
- assert product_ids.next_page?
61
+ assert_equal([4, 3], product_ids)
62
+ assert(product_ids.next_page?)
63
63
 
64
64
  fake(
65
65
  "product_listings/product_ids",
@@ -71,7 +71,7 @@ class ProductListingTest < Test::Unit::TestCase
71
71
  )
72
72
 
73
73
  next_page = product_ids.fetch_next_page
74
- assert_equal [2, 1], next_page
74
+ assert_equal([2, 1], next_page)
75
75
  end
76
76
 
77
77
  def test_get_product_listing_product_ids_multi_page_with_cursor_fails_on_older_api_version
@@ -89,8 +89,8 @@ class ProductListingTest < Test::Unit::TestCase
89
89
  )
90
90
 
91
91
  product_ids = ShopifyAPI::ProductListing.product_ids
92
- assert_equal [4, 3], product_ids
93
- assert_raises NotImplementedError do
92
+ assert_equal([4, 3], product_ids)
93
+ assert_raises(NotImplementedError) do
94
94
  product_ids.next_page?
95
95
  end
96
96
  end
@@ -3,23 +3,23 @@ require 'test_helper'
3
3
 
4
4
  class ProductPublicationTest < Test::Unit::TestCase
5
5
  def test_get_all_product_publications
6
- fake 'publications/55650051/product_publications', body: load_fixture('product_publications')
6
+ fake('publications/55650051/product_publications', body: load_fixture('product_publications'))
7
7
  product_publications = ShopifyAPI::ProductPublication.find(:all, params: { publication_id: 55650051 })
8
8
 
9
- assert_equal 647162527768, product_publications.first.id
10
- assert_equal 55650051, product_publications.first.publication_id
9
+ assert_equal(647162527768, product_publications.first.id)
10
+ assert_equal(55650051, product_publications.first.publication_id)
11
11
  end
12
12
 
13
13
  def test_get_product_publication
14
- fake 'publications/55650051/product_publications/647162527768', body: load_fixture('product_publication')
14
+ fake('publications/55650051/product_publications/647162527768', body: load_fixture('product_publication'))
15
15
  product_publication = ShopifyAPI::ProductPublication.find(647162527768, params: { publication_id: 55650051 })
16
16
 
17
- assert_equal 647162527768, product_publication.id
18
- assert_equal 55650051, product_publication.publication_id
17
+ assert_equal(647162527768, product_publication.id)
18
+ assert_equal(55650051, product_publication.publication_id)
19
19
  end
20
20
 
21
21
  def test_create_product_publication
22
- fake 'publications/55650051/product_publications', method: :post, body: load_fixture('product_publication')
22
+ fake('publications/55650051/product_publications', method: :post, body: load_fixture('product_publication'))
23
23
  ShopifyAPI::ProductPublication.create(
24
24
  publication_id: 55650051,
25
25
  published_at: "2018-01-29T14:06:08-05:00",
@@ -35,6 +35,6 @@ class ProductPublicationTest < 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