shopify_api 4.9.0 → 4.13.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.travis.yml +0 -4
- data/CHANGELOG +18 -0
- data/README.md +28 -12
- data/lib/shopify_api/limits.rb +1 -2
- data/lib/shopify_api/resources/access_scope.rb +5 -0
- data/lib/shopify_api/resources/api_permission.rb +9 -0
- data/lib/shopify_api/resources/asset.rb +8 -8
- data/lib/shopify_api/resources/billing_address.rb +1 -1
- data/lib/shopify_api/resources/custom_collection.rb +3 -3
- data/lib/shopify_api/resources/{customer_invite_message.rb → customer_invite.rb} +0 -0
- data/lib/shopify_api/resources/graphql.rb +22 -0
- data/lib/shopify_api/resources/image.rb +2 -2
- data/lib/shopify_api/resources/inventory_item.rb +6 -0
- data/lib/shopify_api/resources/inventory_level.rb +55 -0
- data/lib/shopify_api/resources/line_item.rb +9 -1
- data/lib/shopify_api/resources/location.rb +4 -0
- data/lib/shopify_api/resources/o_auth.rb +8 -0
- data/lib/shopify_api/resources/order.rb +7 -2
- data/lib/shopify_api/resources/ping.rb +3 -0
- data/lib/shopify_api/resources/ping/conversation.rb +18 -0
- data/lib/shopify_api/resources/ping/message.rb +9 -0
- data/lib/shopify_api/resources/product.rb +4 -4
- data/lib/shopify_api/resources/shipping_line.rb +1 -1
- data/lib/shopify_api/resources/shop.rb +4 -4
- data/lib/shopify_api/version.rb +1 -1
- data/shopify_api.gemspec +2 -1
- data/test/api_permission_test.rb +9 -0
- data/test/fixtures/inventory_level.json +7 -0
- data/test/fixtures/inventory_levels.json +24 -0
- data/test/fixtures/order_with_properties.json +373 -0
- data/test/fixtures/ping/conversation.json +1 -0
- data/test/fixtures/ping/message.json +1 -0
- data/test/inventory_level_test.rb +59 -0
- data/test/location_test.rb +14 -0
- data/test/order_test.rb +13 -1
- data/test/ping/conversation_test.rb +39 -0
- data/test/test_helper.rb +7 -5
- data/test/variant_test.rb +4 -1
- metadata +37 -10
- data/lib/shopify_api/resources/discount.rb +0 -11
- data/test/discount_test.rb +0 -52
- data/test/fixtures/discount.json +0 -17
- data/test/fixtures/discount_disabled.json +0 -17
- data/test/fixtures/discounts.json +0 -34
@@ -0,0 +1 @@
|
|
1
|
+
{"conversation":{"id":"d315d4f7-53bd-49ec-8808-23f6db3c641a","name":"my topic","participants":{"counts":{"total":1},"data":[{"id":"test","name":"foo","avatar":null,"group":"customer"}]},"shopify_account":{"domain":"backpackinghacks.myshopify.com"}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"message":{"id":"d0c7a2e6-8084-4e79-8483-e4a1352b81f7","sender_id":"test","sender":{"id":"test","name":"foo","avatar":null,"group":"customer"},"content":{"text":"Hello from shopify_api"},"sent_at":"2018-08-29T22:16:05.589479Z"}}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class InventoryLevelTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@inventory_level_response = ActiveSupport::JSON.decode load_fixture('inventory_level')
|
7
|
+
@inventory_level = ShopifyAPI::InventoryLevel.new(@inventory_level_response['inventory_level'])
|
8
|
+
end
|
9
|
+
|
10
|
+
test ".find with inventory_item_ids and location_ids returns expected inventory levels" do
|
11
|
+
params = { inventory_item_ids: [808950810, 39072856], location_ids: [905684977, 487838322] }
|
12
|
+
fake "inventory_levels.json?#{params.to_param}", extension: false, method: :get,
|
13
|
+
status: 200, body: load_fixture('inventory_levels')
|
14
|
+
inventory_levels = ShopifyAPI::InventoryLevel.find(:all, params: params)
|
15
|
+
|
16
|
+
assert inventory_levels.all? { |item|
|
17
|
+
params[:location_ids].include?(item.location_id) &&
|
18
|
+
params[:inventory_item_ids].include?(item.inventory_item_id)
|
19
|
+
}, message: 'Response contained inventory_items or locations not requested.'
|
20
|
+
end
|
21
|
+
|
22
|
+
test '#adjust with adjustment value returns inventory_level with available increased by adjustment value' do
|
23
|
+
adjustment = 5
|
24
|
+
updated_available = @inventory_level.available + adjustment
|
25
|
+
@inventory_level_response[:available] = updated_available
|
26
|
+
|
27
|
+
fake 'inventory_levels/adjust', method: :post, body: ActiveSupport::JSON.encode(@inventory_level_response)
|
28
|
+
@inventory_level.adjust(adjustment)
|
29
|
+
assert_equal updated_available, @inventory_level.available
|
30
|
+
end
|
31
|
+
|
32
|
+
test '#connect saves an inventory_level associated with inventory_item and location_id' do
|
33
|
+
params = { inventory_item_id: 808950810, location_id: 99999999 }
|
34
|
+
response = params.clone
|
35
|
+
response[:available] = 0
|
36
|
+
|
37
|
+
fake 'inventory_levels/connect', method: :post, body: ActiveSupport::JSON.encode(response)
|
38
|
+
inventory_level = ShopifyAPI::InventoryLevel.new(params)
|
39
|
+
inventory_level.connect
|
40
|
+
assert_equal 0, inventory_level.available, message: 'expected newly connected location to have 0 inventory'
|
41
|
+
end
|
42
|
+
|
43
|
+
test '#destroy removes inventory_level and returns nil' do
|
44
|
+
params = { inventory_item_id: @inventory_level.inventory_item_id, location_id: @inventory_level.location_id }
|
45
|
+
fake "inventory_levels.json?#{params.to_param}", extension: false, method: :delete, status: 204, body: nil
|
46
|
+
assert_nil @inventory_level.destroy
|
47
|
+
end
|
48
|
+
|
49
|
+
test '#set with available value returns inventory_level with available as the available value' do
|
50
|
+
available = 13
|
51
|
+
response = @inventory_level_response.clone
|
52
|
+
response['inventory_level']['available'] = available
|
53
|
+
|
54
|
+
fake 'inventory_levels/set', method: :post, body: ActiveSupport::JSON.encode(response)
|
55
|
+
@inventory_level.set(available)
|
56
|
+
|
57
|
+
assert_equal available, @inventory_level.available
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class LocationTest < Test::Unit::TestCase
|
4
|
+
test '#inventory_levels returns all inventory_levels associated with this location' do
|
5
|
+
location = ShopifyAPI::Location.new(id: 487838322)
|
6
|
+
expected_body = JSON.parse(load_fixture('inventory_levels'))
|
7
|
+
expected_body['inventory_levels'].delete_if {|level| level['location_id'] != location.id }
|
8
|
+
fake "locations/#{location.id}/inventory_levels", method: :get, status: 200, body: JSON(expected_body).to_s
|
9
|
+
inventory_levels = location.inventory_levels
|
10
|
+
|
11
|
+
assert inventory_levels.all? { |item| item.location_id == location.id },
|
12
|
+
message: 'Response contained locations other than the current location.'
|
13
|
+
end
|
14
|
+
end
|
data/test/order_test.rb
CHANGED
@@ -8,12 +8,25 @@ class OrderTest < Test::Unit::TestCase
|
|
8
8
|
assert_equal 39072856, order.line_items.first.variant_id
|
9
9
|
end
|
10
10
|
|
11
|
+
test "create should create an order with custom properties" do
|
12
|
+
props = [{ :"By default may label with \"Roasted for " => { :"Your First Name" => { :"\". If you want something specific on the label, enter it here:" => "" }}}]
|
13
|
+
fake 'orders', :method => :post, :status => 201, :body => load_fixture('order_with_properties')
|
14
|
+
order = ShopifyAPI::Order.create(line_items: [{quantity:1, variant_id:39072856, properties:props}], financial_status:"authorized")
|
15
|
+
assert_equal 39072856, order.line_items.first.variant_id
|
16
|
+
end
|
17
|
+
|
11
18
|
test "get should get an order" do
|
12
19
|
fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
|
13
20
|
order = ShopifyAPI::Order.find(450789469)
|
14
21
|
assert_equal 450789469, order.id
|
15
22
|
end
|
16
23
|
|
24
|
+
test "get should get an order with custom properties" do
|
25
|
+
fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order_with_properties')
|
26
|
+
order = ShopifyAPI::Order.find(450789469)
|
27
|
+
assert_equal 450789469, order.id
|
28
|
+
end
|
29
|
+
|
17
30
|
test "get all should get all orders" do
|
18
31
|
fake 'orders', :method => :get, :status => 200, :body => load_fixture('orders')
|
19
32
|
order = ShopifyAPI::Order.all
|
@@ -44,4 +57,3 @@ class OrderTest < Test::Unit::TestCase
|
|
44
57
|
assert_request_body({'email' => false, 'restock' => true}.to_json)
|
45
58
|
end
|
46
59
|
end
|
47
|
-
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class PingConversationTest < Test::Unit::TestCase
|
6
|
+
def test_create_conversation
|
7
|
+
fake "api/ping-api/v1/conversations", method: :post, body: load_fixture('ping/conversation')
|
8
|
+
|
9
|
+
conversation = ShopifyAPI::Ping::Conversation.new(
|
10
|
+
topic: 'my topic',
|
11
|
+
participants: [
|
12
|
+
{
|
13
|
+
name: 'foo',
|
14
|
+
id: 'test',
|
15
|
+
group: 'customer',
|
16
|
+
},
|
17
|
+
]
|
18
|
+
)
|
19
|
+
|
20
|
+
conversation.save
|
21
|
+
|
22
|
+
assert_equal "d315d4f7-53bd-49ec-8808-23f6db3c641a", conversation.id
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_send_message
|
26
|
+
fake "api/ping-api/v1/conversations/123/messages", method: :post, body: load_fixture('ping/message')
|
27
|
+
|
28
|
+
conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
|
29
|
+
message = conversation.send_message(
|
30
|
+
dedupe_key: SecureRandom.uuid,
|
31
|
+
content: {
|
32
|
+
text: "Hello from shopify_api",
|
33
|
+
},
|
34
|
+
sender_id: 'test',
|
35
|
+
)
|
36
|
+
|
37
|
+
assert_equal "d0c7a2e6-8084-4e79-8483-e4a1352b81f7", message.id
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -30,11 +30,13 @@ class Test::Unit::TestCase < Minitest::Unit::TestCase
|
|
30
30
|
|
31
31
|
def setup
|
32
32
|
ActiveResource::Base.format = :json
|
33
|
-
ShopifyAPI.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
[ShopifyAPI, ShopifyAPI::Ping].each do |mod|
|
34
|
+
mod.constants.each do |const|
|
35
|
+
begin
|
36
|
+
const = mod.const_get(const)
|
37
|
+
const.format = :json if const.respond_to?(:format=)
|
38
|
+
rescue NameError
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/test/variant_test.rb
CHANGED
@@ -5,19 +5,22 @@ class VariantTest < Test::Unit::TestCase
|
|
5
5
|
def test_get_variants
|
6
6
|
fake "products/632910392/variants", :method => :get, :body => load_fixture('variants')
|
7
7
|
|
8
|
-
|
8
|
+
variants = ShopifyAPI::Variant.find(:all, :params => { :product_id => 632910392 })
|
9
|
+
assert_equal variants.map(&:id).sort, [39072856, 49148385, 457924702, 808950810]
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_get_variant_namespaced
|
12
13
|
fake "products/632910392/variants/808950810", :method => :get, :body => load_fixture('variant')
|
13
14
|
|
14
15
|
v = ShopifyAPI::Variant.find(808950810, :params => {:product_id => 632910392})
|
16
|
+
assert_equal 632910392, v.product_id
|
15
17
|
end
|
16
18
|
|
17
19
|
def test_get_variant
|
18
20
|
fake "variants/808950810", :method => :get, :body => load_fixture('variant')
|
19
21
|
|
20
22
|
v = ShopifyAPI::Variant.find(808950810)
|
23
|
+
assert_equal 632910392, v.product_id
|
21
24
|
end
|
22
25
|
|
23
26
|
def test_product_id_should_be_accessible_if_via_product_endpoint
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: graphql-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: mocha
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,7 @@ extra_rdoc_files:
|
|
122
136
|
files:
|
123
137
|
- ".document"
|
124
138
|
- ".gitignore"
|
139
|
+
- ".rubocop.yml"
|
125
140
|
- ".travis.yml"
|
126
141
|
- CHANGELOG
|
127
142
|
- CONTRIBUTING.md
|
@@ -151,9 +166,11 @@ files:
|
|
151
166
|
- lib/shopify_api/limits.rb
|
152
167
|
- lib/shopify_api/metafields.rb
|
153
168
|
- lib/shopify_api/resources.rb
|
169
|
+
- lib/shopify_api/resources/access_scope.rb
|
154
170
|
- lib/shopify_api/resources/access_token.rb
|
155
171
|
- lib/shopify_api/resources/address.rb
|
156
172
|
- lib/shopify_api/resources/announcement.rb
|
173
|
+
- lib/shopify_api/resources/api_permission.rb
|
157
174
|
- lib/shopify_api/resources/application_charge.rb
|
158
175
|
- lib/shopify_api/resources/application_credit.rb
|
159
176
|
- lib/shopify_api/resources/article.rb
|
@@ -171,9 +188,8 @@ files:
|
|
171
188
|
- lib/shopify_api/resources/custom_collection.rb
|
172
189
|
- lib/shopify_api/resources/customer.rb
|
173
190
|
- lib/shopify_api/resources/customer_group.rb
|
174
|
-
- lib/shopify_api/resources/
|
191
|
+
- lib/shopify_api/resources/customer_invite.rb
|
175
192
|
- lib/shopify_api/resources/customer_saved_search.rb
|
176
|
-
- lib/shopify_api/resources/discount.rb
|
177
193
|
- lib/shopify_api/resources/discount_code.rb
|
178
194
|
- lib/shopify_api/resources/draft_order.rb
|
179
195
|
- lib/shopify_api/resources/draft_order_invoice.rb
|
@@ -183,7 +199,10 @@ files:
|
|
183
199
|
- lib/shopify_api/resources/fulfillment_request.rb
|
184
200
|
- lib/shopify_api/resources/fulfillment_service.rb
|
185
201
|
- lib/shopify_api/resources/gift_card.rb
|
202
|
+
- lib/shopify_api/resources/graphql.rb
|
186
203
|
- lib/shopify_api/resources/image.rb
|
204
|
+
- lib/shopify_api/resources/inventory_item.rb
|
205
|
+
- lib/shopify_api/resources/inventory_level.rb
|
187
206
|
- lib/shopify_api/resources/line_item.rb
|
188
207
|
- lib/shopify_api/resources/location.rb
|
189
208
|
- lib/shopify_api/resources/marketing_event.rb
|
@@ -195,6 +214,9 @@ files:
|
|
195
214
|
- lib/shopify_api/resources/order_risk.rb
|
196
215
|
- lib/shopify_api/resources/page.rb
|
197
216
|
- lib/shopify_api/resources/payment_details.rb
|
217
|
+
- lib/shopify_api/resources/ping.rb
|
218
|
+
- lib/shopify_api/resources/ping/conversation.rb
|
219
|
+
- lib/shopify_api/resources/ping/message.rb
|
198
220
|
- lib/shopify_api/resources/policy.rb
|
199
221
|
- lib/shopify_api/resources/price_rule.rb
|
200
222
|
- lib/shopify_api/resources/product.rb
|
@@ -228,6 +250,7 @@ files:
|
|
228
250
|
- shopify_api.gemspec
|
229
251
|
- test/access_token_test.rb
|
230
252
|
- test/active_resource/json_errors_test.rb
|
253
|
+
- test/api_permission_test.rb
|
231
254
|
- test/application_charge_test.rb
|
232
255
|
- test/application_credit_test.rb
|
233
256
|
- test/article_test.rb
|
@@ -245,7 +268,6 @@ files:
|
|
245
268
|
- test/customer_test.rb
|
246
269
|
- test/detailed_log_subscriber_test.rb
|
247
270
|
- test/discount_code_test.rb
|
248
|
-
- test/discount_test.rb
|
249
271
|
- test/draft_order_test.rb
|
250
272
|
- test/fixtures/access_token_delegate.json
|
251
273
|
- test/fixtures/application_charge.json
|
@@ -273,11 +295,8 @@ files:
|
|
273
295
|
- test/fixtures/customers.json
|
274
296
|
- test/fixtures/customers_account_activation_url.json
|
275
297
|
- test/fixtures/customers_search.json
|
276
|
-
- test/fixtures/discount.json
|
277
298
|
- test/fixtures/discount_code.json
|
278
299
|
- test/fixtures/discount_codes.json
|
279
|
-
- test/fixtures/discount_disabled.json
|
280
|
-
- test/fixtures/discounts.json
|
281
300
|
- test/fixtures/draft_order.json
|
282
301
|
- test/fixtures/draft_order_completed.json
|
283
302
|
- test/fixtures/draft_order_invoice.json
|
@@ -292,6 +311,8 @@ files:
|
|
292
311
|
- test/fixtures/gift_card_disabled.json
|
293
312
|
- test/fixtures/image.json
|
294
313
|
- test/fixtures/images.json
|
314
|
+
- test/fixtures/inventory_level.json
|
315
|
+
- test/fixtures/inventory_levels.json
|
295
316
|
- test/fixtures/marketing_event.json
|
296
317
|
- test/fixtures/marketing_events.json
|
297
318
|
- test/fixtures/metafield.json
|
@@ -300,7 +321,10 @@ files:
|
|
300
321
|
- test/fixtures/order.json
|
301
322
|
- test/fixtures/order_risk.json
|
302
323
|
- test/fixtures/order_risks.json
|
324
|
+
- test/fixtures/order_with_properties.json
|
303
325
|
- test/fixtures/orders.json
|
326
|
+
- test/fixtures/ping/conversation.json
|
327
|
+
- test/fixtures/ping/message.json
|
304
328
|
- test/fixtures/policies.json
|
305
329
|
- test/fixtures/price_rule.json
|
306
330
|
- test/fixtures/price_rules.json
|
@@ -339,12 +363,15 @@ files:
|
|
339
363
|
- test/fulfillment_test.rb
|
340
364
|
- test/gift_card_test.rb
|
341
365
|
- test/image_test.rb
|
366
|
+
- test/inventory_level_test.rb
|
342
367
|
- test/limits_test.rb
|
368
|
+
- test/location_test.rb
|
343
369
|
- test/marketing_event_test.rb
|
344
370
|
- test/metafield_test.rb
|
345
371
|
- test/o_auth_test.rb
|
346
372
|
- test/order_risk_test.rb
|
347
373
|
- test/order_test.rb
|
374
|
+
- test/ping/conversation_test.rb
|
348
375
|
- test/policy_test.rb
|
349
376
|
- test/price_rule_test.rb
|
350
377
|
- test/product_listing_test.rb
|
@@ -380,7 +407,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
380
407
|
requirements:
|
381
408
|
- - ">="
|
382
409
|
- !ruby/object:Gem::Version
|
383
|
-
version: '2.
|
410
|
+
version: '2.1'
|
384
411
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
385
412
|
requirements:
|
386
413
|
- - ">="
|
@@ -388,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
388
415
|
version: '0'
|
389
416
|
requirements: []
|
390
417
|
rubyforge_project:
|
391
|
-
rubygems_version: 2.
|
418
|
+
rubygems_version: 2.6.14
|
392
419
|
signing_key:
|
393
420
|
specification_version: 4
|
394
421
|
summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web
|
data/test/discount_test.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DiscountTest < Test::Unit::TestCase
|
4
|
-
test 'get should get a discount' do
|
5
|
-
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
6
|
-
|
7
|
-
discount = ShopifyAPI::Discount.find(680866)
|
8
|
-
assert_equal 680866, discount.id
|
9
|
-
end
|
10
|
-
|
11
|
-
test 'get should get all discounts' do
|
12
|
-
fake 'discounts', method: :get, status: 200, body: load_fixture('discounts')
|
13
|
-
|
14
|
-
discounts = ShopifyAPI::Discount.all
|
15
|
-
assert_equal 'TENOFF', discounts.first.code
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'create should create a discount' do
|
19
|
-
fake 'discounts', method: :post, status: 201, body: load_fixture('discount')
|
20
|
-
|
21
|
-
discount = ShopifyAPI::Discount.create(code: 'TENOFF', discount_type: 'percentage')
|
22
|
-
assert_equal 'TENOFF', discount.code
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'should disable discount' do
|
26
|
-
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
27
|
-
fake 'discounts/680866/disable', method: :post, status: 201, body: load_fixture('discount_disabled')
|
28
|
-
|
29
|
-
discount = ShopifyAPI::Discount.find(680866)
|
30
|
-
discount.disable
|
31
|
-
|
32
|
-
assert_equal "disabled", discount.status
|
33
|
-
end
|
34
|
-
|
35
|
-
test 'should enable discount' do
|
36
|
-
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
37
|
-
fake 'discounts/680866/enable', method: :post, status: 201, body: load_fixture('discount')
|
38
|
-
|
39
|
-
discount = ShopifyAPI::Discount.find(680866)
|
40
|
-
discount.enable
|
41
|
-
|
42
|
-
assert_equal "enabled", discount.status
|
43
|
-
end
|
44
|
-
|
45
|
-
test 'delete should delete discount' do
|
46
|
-
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
47
|
-
fake 'discounts/680866', method: :delete, status: 200, body: 'destroyed'
|
48
|
-
|
49
|
-
discount = ShopifyAPI::Discount.find(680866)
|
50
|
-
assert discount.destroy
|
51
|
-
end
|
52
|
-
end
|
data/test/fixtures/discount.json
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"discount": {
|
3
|
-
"id": 680866,
|
4
|
-
"code": "TENOFF",
|
5
|
-
"value": "10.0",
|
6
|
-
"ends_at": null,
|
7
|
-
"starts_at": null,
|
8
|
-
"status": "enabled",
|
9
|
-
"minimum_order_amount": "0.00",
|
10
|
-
"usage_limit": null,
|
11
|
-
"applies_to_id": null,
|
12
|
-
"applies_once": false,
|
13
|
-
"discount_type": "percentage",
|
14
|
-
"applies_to_resource": null,
|
15
|
-
"times_used": 1
|
16
|
-
}
|
17
|
-
}
|