shopify_api 9.0.2 → 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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +36 -0
- data/.github/workflows/build.yml +41 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +23 -3
- data/.rubocop_todo.yml +75 -0
- data/CHANGELOG.md +43 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +5 -0
- data/Gemfile.lock +151 -0
- data/Gemfile_ar51 +1 -1
- data/README.md +47 -31
- data/RELEASING +10 -6
- data/Rakefile +16 -5
- data/SECURITY.md +59 -0
- data/docs/_config.yml +1 -0
- data/docs/_includes/footer.html +28 -0
- data/docs/_includes/head.html +28 -0
- data/docs/_layouts/index.html +57 -0
- data/docs/graphql.md +47 -2
- data/docs/index.md +639 -0
- data/lib/active_resource/connection_ext.rb +1 -0
- data/lib/active_resource/detailed_log_subscriber.rb +6 -7
- data/lib/active_resource/json_errors.rb +8 -2
- data/lib/shopify_api.rb +8 -1
- data/lib/shopify_api/api_access.rb +57 -0
- data/lib/shopify_api/api_version.rb +6 -5
- data/lib/shopify_api/connection.rb +1 -0
- data/lib/shopify_api/countable.rb +3 -2
- data/lib/shopify_api/disable_prefix_check.rb +2 -2
- data/lib/shopify_api/events.rb +2 -1
- data/lib/shopify_api/graphql.rb +28 -8
- data/lib/shopify_api/limits.rb +3 -2
- data/lib/shopify_api/message_enricher.rb +11 -9
- data/lib/shopify_api/meta.rb +0 -1
- data/lib/shopify_api/metafields.rb +5 -4
- data/lib/shopify_api/pagination_link_headers.rb +5 -4
- data/lib/shopify_api/resources.rb +1 -0
- data/lib/shopify_api/resources/access_scope.rb +1 -1
- data/lib/shopify_api/resources/access_token.rb +1 -0
- data/lib/shopify_api/resources/address.rb +1 -0
- data/lib/shopify_api/resources/announcement.rb +2 -1
- data/lib/shopify_api/resources/application_charge.rb +1 -0
- data/lib/shopify_api/resources/application_credit.rb +1 -0
- data/lib/shopify_api/resources/article.rb +3 -2
- data/lib/shopify_api/resources/asset.rb +6 -5
- data/lib/shopify_api/resources/assigned_fulfillment_order.rb +1 -1
- data/lib/shopify_api/resources/base.rb +12 -8
- data/lib/shopify_api/resources/billing_address.rb +1 -0
- data/lib/shopify_api/resources/blog.rb +2 -1
- data/lib/shopify_api/resources/carrier_service.rb +1 -0
- data/lib/shopify_api/resources/cart.rb +2 -1
- data/lib/shopify_api/resources/collect.rb +1 -0
- data/lib/shopify_api/resources/collection_listing.rb +1 -0
- data/lib/shopify_api/resources/comment.rb +20 -5
- data/lib/shopify_api/resources/country.rb +1 -0
- data/lib/shopify_api/resources/custom_collection.rb +4 -3
- data/lib/shopify_api/resources/customer.rb +2 -1
- data/lib/shopify_api/resources/customer_group.rb +1 -0
- data/lib/shopify_api/resources/customer_invite.rb +1 -0
- data/lib/shopify_api/resources/customer_saved_search.rb +2 -1
- data/lib/shopify_api/resources/discount_code.rb +1 -0
- data/lib/shopify_api/resources/discount_code_batch.rb +34 -0
- data/lib/shopify_api/resources/draft_order.rb +1 -0
- data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
- data/lib/shopify_api/resources/event.rb +1 -0
- data/lib/shopify_api/resources/fulfillment.rb +12 -3
- data/lib/shopify_api/resources/fulfillment_event.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_order.rb +30 -16
- data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_v2.rb +3 -2
- data/lib/shopify_api/resources/gift_card.rb +1 -0
- data/lib/shopify_api/resources/image.rb +2 -1
- data/lib/shopify_api/resources/inventory_level.rb +3 -4
- data/lib/shopify_api/resources/line_item.rb +4 -3
- data/lib/shopify_api/resources/location.rb +1 -1
- data/lib/shopify_api/resources/marketing_event.rb +1 -0
- data/lib/shopify_api/resources/metafield.rb +1 -0
- data/lib/shopify_api/resources/note_attribute.rb +1 -0
- data/lib/shopify_api/resources/option.rb +1 -0
- data/lib/shopify_api/resources/order.rb +2 -1
- data/lib/shopify_api/resources/order_risk.rb +1 -0
- data/lib/shopify_api/resources/page.rb +1 -0
- data/lib/shopify_api/resources/payment_details.rb +1 -0
- data/lib/shopify_api/resources/policy.rb +1 -0
- data/lib/shopify_api/resources/price_rule.rb +1 -1
- data/lib/shopify_api/resources/product.rb +27 -3
- data/lib/shopify_api/resources/product_listing.rb +1 -0
- data/lib/shopify_api/resources/province.rb +1 -0
- data/lib/shopify_api/resources/receipt.rb +1 -0
- data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
- data/lib/shopify_api/resources/redirect.rb +1 -0
- data/lib/shopify_api/resources/refund.rb +2 -1
- data/lib/shopify_api/resources/report.rb +1 -0
- data/lib/shopify_api/resources/resource_feedback.rb +1 -1
- data/lib/shopify_api/resources/rule.rb +1 -0
- data/lib/shopify_api/resources/script_tag.rb +1 -0
- data/lib/shopify_api/resources/shipping_address.rb +1 -0
- data/lib/shopify_api/resources/shipping_line.rb +1 -0
- data/lib/shopify_api/resources/shipping_zone.rb +1 -0
- data/lib/shopify_api/resources/shop.rb +2 -1
- data/lib/shopify_api/resources/smart_collection.rb +4 -8
- data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
- data/lib/shopify_api/resources/tax_line.rb +1 -0
- data/lib/shopify_api/resources/tax_service.rb +1 -0
- data/lib/shopify_api/resources/theme.rb +1 -0
- data/lib/shopify_api/resources/transaction.rb +1 -0
- data/lib/shopify_api/resources/usage_charge.rb +1 -0
- data/lib/shopify_api/resources/user.rb +1 -0
- data/lib/shopify_api/resources/variant.rb +35 -0
- data/lib/shopify_api/resources/webhook.rb +1 -0
- data/lib/shopify_api/session.rb +43 -14
- data/lib/shopify_api/version.rb +2 -1
- data/lib/verify_docs.rb +8 -0
- data/service.yml +1 -1
- data/shopify_api.gemspec +13 -6
- data/test/access_token_test.rb +6 -5
- data/test/active_resource/json_errors_test.rb +6 -6
- data/test/api_access_test.rb +153 -0
- data/test/api_version_test.rb +3 -3
- data/test/application_charge_test.rb +30 -27
- data/test/application_credit_test.rb +10 -9
- data/test/article_test.rb +34 -35
- data/test/asset_test.rb +14 -6
- data/test/assigned_fulfillment_order_test.rb +5 -4
- data/test/base_test.rb +64 -49
- data/test/blog_test.rb +4 -3
- data/test/carrier_service_test.rb +7 -6
- data/test/cart_test.rb +2 -1
- data/test/collect_test.rb +4 -3
- data/test/collection_listing_test.rb +21 -16
- data/test/collection_publication_test.rb +8 -8
- data/test/collection_test.rb +20 -19
- data/test/countable_test.rb +3 -2
- data/test/currency_test.rb +5 -5
- data/test/custom_collection_test.rb +4 -3
- data/test/customer_saved_search_test.rb +18 -8
- data/test/customer_test.rb +22 -14
- data/test/detailed_log_subscriber_test.rb +15 -11
- data/test/discount_code_batch_test.rb +41 -0
- data/test/discount_code_test.rb +21 -15
- data/test/draft_order_test.rb +68 -52
- data/test/fixtures/assigned_fulfillment_orders.json +2 -0
- data/test/fixtures/discount_code_batch.json +14 -0
- data/test/fixtures/discount_code_batch_discount_codes.json +21 -0
- data/test/fixtures/fulfillment_order.json +1 -0
- data/test/fixtures/fulfillment_orders.json +2 -0
- data/test/fulfillment_event_test.rb +31 -26
- data/test/fulfillment_order_test.rb +215 -147
- data/test/fulfillment_order_test_helper.rb +1 -0
- data/test/fulfillment_request_test.rb +10 -8
- data/test/fulfillment_service_test.rb +13 -12
- data/test/fulfillment_test.rb +81 -66
- data/test/fulfillment_v2_test.rb +16 -12
- data/test/gift_card_test.rb +6 -4
- data/test/graphql_test.rb +55 -23
- data/test/image_test.rb +19 -17
- data/test/inventory_level_test.rb +24 -15
- data/test/lib/webmock_extensions/last_request.rb +1 -1
- data/test/limits_test.rb +2 -1
- data/test/location_test.rb +2 -1
- data/test/marketing_event_test.rb +20 -20
- data/test/message_enricher_test.rb +6 -6
- data/test/meta_test.rb +7 -9
- data/test/metafield_test.rb +30 -20
- data/test/order_risk_test.rb +17 -16
- data/test/order_test.rb +43 -28
- data/test/pagination_test.rb +89 -56
- data/test/policy_test.rb +6 -5
- data/test/price_rule_test.rb +20 -15
- data/test/product_listing_test.rb +20 -20
- data/test/product_publication_test.rb +8 -8
- data/test/product_test.rb +71 -20
- data/test/publication_test.rb +3 -3
- data/test/recurring_application_charge_test.rb +104 -42
- data/test/redirect_test.rb +4 -3
- data/test/refund_test.rb +22 -17
- data/test/report_test.rb +12 -10
- data/test/resource_feedback_test.rb +14 -13
- data/test/script_tag_test.rb +10 -9
- data/test/session_test.rb +234 -43
- data/test/shipping_zone_test.rb +4 -3
- data/test/shop_test.rb +47 -33
- data/test/smart_collection_test.rb +5 -29
- data/test/storefront_access_token_test.rb +13 -15
- data/test/tax_service_test.rb +7 -4
- data/test/tender_transaction_test.rb +3 -3
- data/test/test_helper.rb +14 -12
- data/test/transaction_test.rb +4 -3
- data/test/usage_charge_test.rb +12 -8
- data/test/user_test.rb +4 -3
- data/test/variant_test.rb +50 -23
- data/test/webhook_test.rb +10 -7
- metadata +30 -15
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1027
- data/.travis.yml +0 -23
- data/bin/shopify +0 -3
|
@@ -1,79 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'test_helper'
|
|
2
3
|
|
|
3
4
|
class ApplicationChargeTest < Test::Unit::TestCase
|
|
4
|
-
|
|
5
5
|
def test_application_charge_create
|
|
6
|
-
fake
|
|
6
|
+
fake("application_charges", method: :post, status: 201, body: load_fixture('application_charge'))
|
|
7
7
|
|
|
8
8
|
charge = ShopifyAPI::ApplicationCharge.create(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
name: "iPod Cleaning",
|
|
10
|
+
price: 5.00,
|
|
11
|
+
return_url: "http://google.com"
|
|
12
12
|
)
|
|
13
13
|
|
|
14
|
-
assert_equal
|
|
14
|
+
assert_equal(
|
|
15
|
+
'https://this-is-my-test-shop.myshopify.com/admin/charges/803742/confirm_application_charge?' \
|
|
16
|
+
'signature=BAhpA55DDA%3D%3D--55b44e274e438c619be4631c804abcbcb6ee915a',
|
|
17
|
+
charge.confirmation_url
|
|
18
|
+
)
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
def test_get_application_charge
|
|
18
|
-
fake
|
|
22
|
+
fake("application_charges/803742", method: :get, status: 201, body: load_fixture('application_charge'))
|
|
19
23
|
|
|
20
24
|
charge = ShopifyAPI::ApplicationCharge.find(803742)
|
|
21
25
|
|
|
22
|
-
assert_equal
|
|
26
|
+
assert_equal("iPod Cleaning", charge.name)
|
|
23
27
|
end
|
|
24
28
|
|
|
25
29
|
def test_list_application_charges
|
|
26
|
-
fake
|
|
30
|
+
fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
|
|
27
31
|
|
|
28
32
|
charges = ShopifyAPI::ApplicationCharge.find(:all)
|
|
29
33
|
|
|
30
|
-
assert_equal
|
|
31
|
-
assert_equal
|
|
34
|
+
assert_equal(4, charges.size)
|
|
35
|
+
assert_equal("iPhone Case", charges.last.name)
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def test_list_pending_application_charges
|
|
35
|
-
fake
|
|
39
|
+
fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
|
|
36
40
|
|
|
37
41
|
pending_charges = ShopifyAPI::ApplicationCharge.pending
|
|
38
42
|
|
|
39
|
-
assert_equal
|
|
40
|
-
assert_equal
|
|
43
|
+
assert_equal(1, pending_charges.size)
|
|
44
|
+
assert_equal("Screen Replacement", pending_charges.first.name)
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
def test_list_expired_application_charges
|
|
44
|
-
fake
|
|
48
|
+
fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
|
|
45
49
|
|
|
46
50
|
expired_charges = ShopifyAPI::ApplicationCharge.expired
|
|
47
51
|
|
|
48
|
-
assert_equal
|
|
49
|
-
assert_equal
|
|
52
|
+
assert_equal(1, expired_charges.size)
|
|
53
|
+
assert_equal("iPod Cleaning", expired_charges.first.name)
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
def test_list_accepted_application_charges
|
|
53
|
-
fake
|
|
57
|
+
fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
|
|
54
58
|
|
|
55
59
|
accepted_charges = ShopifyAPI::ApplicationCharge.accepted
|
|
56
60
|
|
|
57
|
-
assert_equal
|
|
58
|
-
assert_equal
|
|
61
|
+
assert_equal(1, accepted_charges.size)
|
|
62
|
+
assert_equal("iPhone Case", accepted_charges.first.name)
|
|
59
63
|
end
|
|
60
64
|
|
|
61
65
|
def test_list_declined_application_charges
|
|
62
|
-
fake
|
|
66
|
+
fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
|
|
63
67
|
|
|
64
68
|
declined_charges = ShopifyAPI::ApplicationCharge.declined
|
|
65
69
|
|
|
66
|
-
assert_equal
|
|
67
|
-
assert_equal
|
|
70
|
+
assert_equal(1, declined_charges.size)
|
|
71
|
+
assert_equal("Magic Mouse", declined_charges.first.name)
|
|
68
72
|
end
|
|
69
73
|
|
|
70
74
|
def test_activate_application_charge
|
|
71
|
-
fake
|
|
72
|
-
fake
|
|
75
|
+
fake("application_charges", method: :get, status: 201, body: load_fixture('application_charges'))
|
|
76
|
+
fake("application_charges/803740/activate", method: :post, status: 200, body: "{}")
|
|
73
77
|
|
|
74
78
|
charge = ShopifyAPI::ApplicationCharge.accepted
|
|
75
79
|
|
|
76
|
-
assert
|
|
80
|
+
assert(charge.last.activate)
|
|
77
81
|
end
|
|
78
|
-
|
|
79
82
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'test_helper'
|
|
2
3
|
|
|
3
4
|
class ApplicationCreditTest < Test::Unit::TestCase
|
|
4
5
|
def test_application_credit_create
|
|
5
|
-
fake
|
|
6
|
+
fake("application_credits", method: :post, status: 201, body: load_fixture('application_credit'))
|
|
6
7
|
|
|
7
8
|
credit = ShopifyAPI::ApplicationCredit.create(
|
|
8
9
|
description: "refund for application charge",
|
|
@@ -11,25 +12,25 @@ class ApplicationCreditTest < Test::Unit::TestCase
|
|
|
11
12
|
shop_id: 487168
|
|
12
13
|
)
|
|
13
14
|
|
|
14
|
-
assert_equal
|
|
15
|
-
assert_equal
|
|
15
|
+
assert_equal('refund for application charge', credit.description)
|
|
16
|
+
assert_equal('5.00', credit.amount)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def test_get_application_credit
|
|
19
|
-
fake
|
|
20
|
+
fake("application_credits/803742", method: :get, status: 201, body: load_fixture('application_credit'))
|
|
20
21
|
|
|
21
22
|
credit = ShopifyAPI::ApplicationCredit.find(803742)
|
|
22
23
|
|
|
23
|
-
assert_equal
|
|
24
|
-
assert_equal
|
|
24
|
+
assert_equal('refund for application charge', credit.description)
|
|
25
|
+
assert_equal('5.00', credit.amount)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def test_list_application_credits
|
|
28
|
-
fake
|
|
29
|
+
fake("application_credits", method: :get, status: 201, body: load_fixture('application_credits'))
|
|
29
30
|
|
|
30
31
|
credit = ShopifyAPI::ApplicationCredit.find(:all)
|
|
31
32
|
|
|
32
|
-
assert_equal
|
|
33
|
-
assert_equal
|
|
33
|
+
assert_equal(2, credit.size)
|
|
34
|
+
assert_equal('10.00', credit.last.amount)
|
|
34
35
|
end
|
|
35
36
|
end
|
data/test/article_test.rb
CHANGED
|
@@ -1,73 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'test_helper'
|
|
2
3
|
|
|
3
4
|
class ArticleTest < Test::Unit::TestCase
|
|
4
|
-
|
|
5
5
|
def test_create_article
|
|
6
|
-
fake
|
|
7
|
-
article = ShopifyAPI::Article.new(:
|
|
6
|
+
fake("blogs/1008414260/articles", method: :post, body: load_fixture('article'))
|
|
7
|
+
article = ShopifyAPI::Article.new(blog_id: 1008414260)
|
|
8
8
|
article.save
|
|
9
|
-
assert_equal
|
|
9
|
+
assert_equal("First Post", article.title)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def test_get_article
|
|
13
|
-
fake
|
|
13
|
+
fake("articles/6242736", method: :get, body: load_fixture('article'))
|
|
14
14
|
article = ShopifyAPI::Article.find(6242736)
|
|
15
|
-
assert_equal
|
|
16
|
-
assert_equal
|
|
15
|
+
assert_equal("First Post", article.title)
|
|
16
|
+
assert_equal(1008414260, article.blog_id)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def test_get_articles
|
|
20
|
-
fake
|
|
20
|
+
fake("articles", method: :get, body: load_fixture('articles'))
|
|
21
21
|
articles = ShopifyAPI::Article.all
|
|
22
|
-
assert_equal
|
|
23
|
-
assert_equal
|
|
22
|
+
assert_equal(3, articles.length)
|
|
23
|
+
assert_equal(1008414260, articles.first.blog_id)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def test_get_articles_namespaced
|
|
27
|
-
fake
|
|
28
|
-
articles = ShopifyAPI::Article.find(:all, :
|
|
29
|
-
assert_equal
|
|
30
|
-
assert_equal
|
|
27
|
+
fake("blogs/1008414260/articles", method: :get, body: load_fixture('articles'))
|
|
28
|
+
articles = ShopifyAPI::Article.find(:all, params: { blog_id: 1008414260 })
|
|
29
|
+
assert_equal(3, articles.length)
|
|
30
|
+
assert_equal(1008414260, articles.first.blog_id)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def test_get_article_namespaced
|
|
34
|
-
fake
|
|
35
|
-
article = ShopifyAPI::Article.find(6242736, :
|
|
36
|
-
assert_equal
|
|
37
|
-
assert_equal
|
|
34
|
+
fake("blogs/1008414260/articles/6242736", method: :get, body: load_fixture('article'))
|
|
35
|
+
article = ShopifyAPI::Article.find(6242736, params: { blog_id: 1008414260 })
|
|
36
|
+
assert_equal("First Post", article.title)
|
|
37
|
+
assert_equal(1008414260, article.blog_id)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def test_get_authors
|
|
41
|
-
fake
|
|
41
|
+
fake("articles/authors", method: :get, body: load_fixture('authors'))
|
|
42
42
|
authors = ShopifyAPI::Article.authors
|
|
43
|
-
assert_equal
|
|
44
|
-
assert_equal
|
|
43
|
+
assert_equal("Shopify", authors.first)
|
|
44
|
+
assert_equal("development shop", authors.last)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def test_get_authors_for_blog_id
|
|
48
|
-
fake
|
|
49
|
-
authors = ShopifyAPI::Article.authors(:
|
|
50
|
-
assert_equal
|
|
48
|
+
fake("blogs/1008414260/articles/authors", method: :get, body: load_fixture('authors'))
|
|
49
|
+
authors = ShopifyAPI::Article.authors(blog_id: 1008414260)
|
|
50
|
+
assert_equal(3, authors.length)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def test_get_tags
|
|
54
|
-
fake
|
|
54
|
+
fake("articles/tags", method: :get, body: load_fixture('tags'))
|
|
55
55
|
tags = ShopifyAPI::Article.tags
|
|
56
|
-
assert_equal
|
|
57
|
-
assert_equal
|
|
56
|
+
assert_equal("consequuntur", tags.first)
|
|
57
|
+
assert_equal("repellendus", tags.last)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def test_get_tags_for_blog_id
|
|
61
|
-
fake
|
|
62
|
-
tags = ShopifyAPI::Article.tags(:
|
|
63
|
-
assert_equal
|
|
64
|
-
assert_equal
|
|
61
|
+
fake("blogs/1008414260/articles/tags", method: :get, body: load_fixture('tags'))
|
|
62
|
+
tags = ShopifyAPI::Article.tags(blog_id: 1008414260)
|
|
63
|
+
assert_equal("consequuntur", tags.first)
|
|
64
|
+
assert_equal("repellendus", tags.last)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def test_get_popular_tags
|
|
68
|
-
fake
|
|
69
|
-
tags = ShopifyAPI::Article.tags(:
|
|
70
|
-
assert_equal
|
|
68
|
+
fake("articles/tags.json?limit=1&popular=1", extension: false, method: :get, body: load_fixture('tags'))
|
|
69
|
+
tags = ShopifyAPI::Article.tags(popular: 1, limit: 1)
|
|
70
|
+
assert_equal(3, tags.length)
|
|
71
71
|
end
|
|
72
|
-
|
|
73
72
|
end
|
data/test/asset_test.rb
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'test_helper'
|
|
2
3
|
|
|
3
4
|
class AssetTest < Test::Unit::TestCase
|
|
4
5
|
def test_get_assetss
|
|
5
|
-
fake
|
|
6
|
-
|
|
6
|
+
fake("themes/1/assets", method: :get, body: load_fixture('assets'))
|
|
7
|
+
ShopifyAPI::Asset.find(:all, params: { theme_id: 1 })
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
def test_get_asset_namespaced
|
|
10
|
-
fake
|
|
11
|
-
|
|
11
|
+
fake(
|
|
12
|
+
"themes/1/assets.json?asset%5Bkey%5D=templates%2Findex.liquid&theme_id=1",
|
|
13
|
+
extension: false,
|
|
14
|
+
method: :get,
|
|
15
|
+
body: load_fixture('asset')
|
|
16
|
+
)
|
|
17
|
+
ShopifyAPI::Asset.find('templates/index.liquid', params: { theme_id: 1 })
|
|
12
18
|
end
|
|
13
19
|
|
|
14
20
|
def test_get_asset
|
|
15
|
-
fake
|
|
16
|
-
|
|
21
|
+
fake(
|
|
22
|
+
"assets.json?asset%5Bkey%5D=templates%2Findex.liquid", extension: false, method: :get, body: load_fixture('asset')
|
|
23
|
+
)
|
|
24
|
+
ShopifyAPI::Asset.find('templates/index.liquid')
|
|
17
25
|
end
|
|
18
26
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'test_helper'
|
|
2
3
|
require 'fulfillment_order_test_helper'
|
|
3
4
|
|
|
@@ -15,7 +16,7 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
|
|
|
15
16
|
should "raise NotImplementedError when api_version is older than 2020-01" do
|
|
16
17
|
url_prefix_for_activated_session_for('2019-10')
|
|
17
18
|
|
|
18
|
-
assert_raises
|
|
19
|
+
assert_raises(NotImplementedError) do
|
|
19
20
|
ShopifyAPI::AssignedFulfillmentOrder.new(ActiveSupport::JSON.decode(@fulfillment_order_fixture))
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -31,7 +32,7 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
|
|
|
31
32
|
body: @fulfillment_order_fixture,
|
|
32
33
|
extension: false
|
|
33
34
|
|
|
34
|
-
assert_raises
|
|
35
|
+
assert_raises(NotImplementedError) do
|
|
35
36
|
ShopifyAPI::AssignedFulfillmentOrder.all(params: { assigned_status: 'cancellation_requested' })
|
|
36
37
|
end
|
|
37
38
|
end
|
|
@@ -44,7 +45,7 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
|
|
|
44
45
|
extension: false
|
|
45
46
|
|
|
46
47
|
assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
|
|
47
|
-
|
|
48
|
+
params: { assigned_status: 'cancellation_requested' }
|
|
48
49
|
)
|
|
49
50
|
|
|
50
51
|
assert_equal 2, assigned_fulfillment_orders.count
|
|
@@ -63,7 +64,7 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
|
|
|
63
64
|
body: @fulfillment_order_fixture, extension: false
|
|
64
65
|
|
|
65
66
|
assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
|
|
66
|
-
|
|
67
|
+
params: { location_ids: [assigned_location_id] }
|
|
67
68
|
)
|
|
68
69
|
|
|
69
70
|
assert_equal 2, assigned_fulfillment_orders.count
|
data/test/base_test.rb
CHANGED
|
@@ -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
|
|
|
@@ -14,77 +15,92 @@ class BaseTest < Test::Unit::TestCase
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
test '#activate_session should set site and headers for given session' do
|
|
17
|
-
ShopifyAPI::Base.activate_session
|
|
18
|
+
ShopifyAPI::Base.activate_session(@session1)
|
|
18
19
|
|
|
19
|
-
assert_nil
|
|
20
|
-
assert_equal
|
|
21
|
-
assert_equal
|
|
20
|
+
assert_nil(ActiveResource::Base.site)
|
|
21
|
+
assert_equal('https://shop1.myshopify.com', ShopifyAPI::Base.site.to_s)
|
|
22
|
+
assert_equal('https://shop1.myshopify.com', ShopifyAPI::Shop.site.to_s)
|
|
22
23
|
|
|
23
|
-
assert_nil
|
|
24
|
-
assert_equal
|
|
25
|
-
assert_equal
|
|
24
|
+
assert_nil(ActiveResource::Base.headers['X-Shopify-Access-Token'])
|
|
25
|
+
assert_equal('token1', ShopifyAPI::Base.headers['X-Shopify-Access-Token'])
|
|
26
|
+
assert_equal('token1', ShopifyAPI::Shop.headers['X-Shopify-Access-Token'])
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
test '#clear_session should clear base site settings from Base' do
|
|
29
30
|
ShopifyAPI::Base.site = "https://foo:bar@www.zombo.com"
|
|
30
31
|
|
|
31
|
-
assert_equal
|
|
32
|
-
assert_equal
|
|
32
|
+
assert_equal("foo", ShopifyAPI::Base.user)
|
|
33
|
+
assert_equal("bar", ShopifyAPI::Base.password)
|
|
33
34
|
|
|
34
35
|
ShopifyAPI::Base.clear_session
|
|
35
36
|
|
|
36
|
-
assert_nil
|
|
37
|
-
assert_nil
|
|
38
|
-
assert_nil
|
|
37
|
+
assert_nil(ShopifyAPI::Base.user)
|
|
38
|
+
assert_nil(ShopifyAPI::Base.password)
|
|
39
|
+
assert_nil(ShopifyAPI::Base.site)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# test to check session reset api version remains the same after session reset
|
|
43
|
+
test '#clear_session should not change the api_version' do
|
|
44
|
+
ShopifyAPI::Base.site = "https://zoo:lion@www.zoo.com"
|
|
45
|
+
|
|
46
|
+
assert_equal("zoo", ShopifyAPI::Base.user)
|
|
47
|
+
assert_equal("lion", ShopifyAPI::Base.password)
|
|
48
|
+
|
|
49
|
+
ShopifyAPI::Base.clear_session
|
|
50
|
+
|
|
51
|
+
assert_nil(ShopifyAPI::Base.user)
|
|
52
|
+
assert_nil(ShopifyAPI::Base.password)
|
|
53
|
+
assert_nil(ShopifyAPI::Base.site)
|
|
54
|
+
assert_equal(ShopifyAPI::Base.api_version, @session1.api_version)
|
|
39
55
|
end
|
|
40
56
|
|
|
41
57
|
test '#clear_session should clear site and headers from Base' do
|
|
42
|
-
ShopifyAPI::Base.activate_session
|
|
58
|
+
ShopifyAPI::Base.activate_session(@session1)
|
|
43
59
|
ShopifyAPI::Base.clear_session
|
|
44
60
|
|
|
45
|
-
assert_nil
|
|
46
|
-
assert_nil
|
|
47
|
-
assert_nil
|
|
61
|
+
assert_nil(ActiveResource::Base.site)
|
|
62
|
+
assert_nil(ShopifyAPI::Base.site)
|
|
63
|
+
assert_nil(ShopifyAPI::Shop.site)
|
|
48
64
|
|
|
49
|
-
assert_nil
|
|
50
|
-
assert_nil
|
|
51
|
-
assert_nil
|
|
65
|
+
assert_nil(ActiveResource::Base.headers['X-Shopify-Access-Token'])
|
|
66
|
+
assert_nil(ShopifyAPI::Base.headers['X-Shopify-Access-Token'])
|
|
67
|
+
assert_nil(ShopifyAPI::Shop.headers['X-Shopify-Access-Token'])
|
|
52
68
|
end
|
|
53
69
|
|
|
54
70
|
test '#activate_session with one session, then clearing and activating with another session should send request to correct shop' do
|
|
55
|
-
ShopifyAPI::Base.activate_session
|
|
71
|
+
ShopifyAPI::Base.activate_session(@session1)
|
|
56
72
|
ShopifyAPI::Base.clear_session
|
|
57
|
-
ShopifyAPI::Base.activate_session
|
|
73
|
+
ShopifyAPI::Base.activate_session(@session2)
|
|
58
74
|
|
|
59
|
-
assert_nil
|
|
60
|
-
assert_equal
|
|
61
|
-
assert_equal
|
|
75
|
+
assert_nil(ActiveResource::Base.site)
|
|
76
|
+
assert_equal('https://shop2.myshopify.com', ShopifyAPI::Base.site.to_s)
|
|
77
|
+
assert_equal('https://shop2.myshopify.com', ShopifyAPI::Shop.site.to_s)
|
|
62
78
|
|
|
63
|
-
assert_nil
|
|
64
|
-
assert_equal
|
|
65
|
-
assert_equal
|
|
79
|
+
assert_nil(ActiveResource::Base.headers['X-Shopify-Access-Token'])
|
|
80
|
+
assert_equal('token2', ShopifyAPI::Base.headers['X-Shopify-Access-Token'])
|
|
81
|
+
assert_equal('token2', ShopifyAPI::Shop.headers['X-Shopify-Access-Token'])
|
|
66
82
|
end
|
|
67
83
|
|
|
68
84
|
test '#activate_session with nil raises an InvalidSessionError' do
|
|
69
|
-
assert_raises
|
|
70
|
-
ShopifyAPI::Base.activate_session
|
|
85
|
+
assert_raises(ShopifyAPI::Base::InvalidSessionError) do
|
|
86
|
+
ShopifyAPI::Base.activate_session(nil)
|
|
71
87
|
end
|
|
72
88
|
end
|
|
73
89
|
|
|
74
90
|
test "#delete should send custom headers with request" do
|
|
75
|
-
ShopifyAPI::Base.activate_session
|
|
91
|
+
ShopifyAPI::Base.activate_session(@session1)
|
|
76
92
|
ShopifyAPI::Base.headers['X-Custom'] = 'abc'
|
|
77
93
|
ShopifyAPI::Base.connection
|
|
78
94
|
.expects(:delete)
|
|
79
95
|
.with('/admin/api/2019-01/bases/1.json', has_entry('X-Custom', 'abc'))
|
|
80
|
-
ShopifyAPI::Base.delete
|
|
96
|
+
ShopifyAPI::Base.delete("1")
|
|
81
97
|
end
|
|
82
98
|
|
|
83
99
|
test "#headers includes the User-Agent" do
|
|
84
100
|
assert_not_includes ActiveResource::Base.headers.keys, 'User-Agent'
|
|
85
|
-
assert_includes
|
|
101
|
+
assert_includes(ShopifyAPI::Base.headers.keys, 'User-Agent')
|
|
86
102
|
thread = Thread.new do
|
|
87
|
-
assert_includes
|
|
103
|
+
assert_includes(ShopifyAPI::Base.headers.keys, 'User-Agent')
|
|
88
104
|
end
|
|
89
105
|
thread.join
|
|
90
106
|
end
|
|
@@ -100,28 +116,28 @@ class BaseTest < Test::Unit::TestCase
|
|
|
100
116
|
end
|
|
101
117
|
|
|
102
118
|
test "prefix= will raise an error if value starts with with /admin" do
|
|
103
|
-
assert_raises
|
|
119
|
+
assert_raises(ArgumentError) do
|
|
104
120
|
TestResource.prefix = '/admin/old/prefix/structure/'
|
|
105
121
|
end
|
|
106
122
|
end
|
|
107
123
|
|
|
108
124
|
test "#headers propagates changes to subclasses" do
|
|
109
125
|
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
|
110
|
-
assert_equal
|
|
111
|
-
assert_equal
|
|
126
|
+
assert_equal("the value", ShopifyAPI::Base.headers['X-Custom'])
|
|
127
|
+
assert_equal("the value", ShopifyAPI::Product.headers['X-Custom'])
|
|
112
128
|
end
|
|
113
129
|
|
|
114
130
|
test "#headers clears changes to subclasses" do
|
|
115
131
|
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
|
116
|
-
assert_equal
|
|
132
|
+
assert_equal("the value", ShopifyAPI::Product.headers['X-Custom'])
|
|
117
133
|
ShopifyAPI::Base.headers['X-Custom'] = nil
|
|
118
|
-
assert_nil
|
|
134
|
+
assert_nil(ShopifyAPI::Product.headers['X-Custom'])
|
|
119
135
|
end
|
|
120
136
|
|
|
121
137
|
test "#headers set in the main thread affect spawned threads" do
|
|
122
138
|
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
|
123
139
|
Thread.new do
|
|
124
|
-
assert_equal
|
|
140
|
+
assert_equal("the value", ShopifyAPI::Base.headers['X-Custom'])
|
|
125
141
|
end.join
|
|
126
142
|
end
|
|
127
143
|
|
|
@@ -129,7 +145,7 @@ class BaseTest < Test::Unit::TestCase
|
|
|
129
145
|
Thread.new do
|
|
130
146
|
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
|
131
147
|
end.join
|
|
132
|
-
assert_nil
|
|
148
|
+
assert_nil(ShopifyAPI::Base.headers['X-Custom'])
|
|
133
149
|
end
|
|
134
150
|
|
|
135
151
|
test "using a different version changes the url" do
|
|
@@ -152,41 +168,40 @@ class BaseTest < Test::Unit::TestCase
|
|
|
152
168
|
)
|
|
153
169
|
|
|
154
170
|
ShopifyAPI::Base.activate_session(release_2019_01)
|
|
155
|
-
assert_equal
|
|
171
|
+
assert_equal(1, ShopifyAPI::Shop.current.id)
|
|
156
172
|
|
|
157
173
|
ShopifyAPI::Base.activate_session(unstable_version)
|
|
158
|
-
assert_equal
|
|
174
|
+
assert_equal(2, ShopifyAPI::Shop.current.id)
|
|
159
175
|
end
|
|
160
176
|
|
|
161
177
|
test "#api_version= should set ApiVersion" do
|
|
162
178
|
ShopifyAPI::Base.api_version = '2019-04'
|
|
163
|
-
assert_equal
|
|
179
|
+
assert_equal('2019-04', ShopifyAPI::Base.api_version.to_s)
|
|
164
180
|
end
|
|
165
181
|
|
|
166
182
|
test "#api_version= nil should set ApiVersion to ShopifyAPI::ApiVersion::NullVersion" do
|
|
167
183
|
ShopifyAPI::Base.api_version = nil
|
|
168
|
-
assert_equal
|
|
184
|
+
assert_equal(ShopifyAPI::ApiVersion::NullVersion, ShopifyAPI::Base.api_version)
|
|
169
185
|
end
|
|
170
186
|
|
|
171
187
|
test "#api_version= ShopifyAPI::ApiVersion::NullVersion should set ApiVersion to ShopifyAPI::ApiVersion::NullVersion" do
|
|
172
188
|
ShopifyAPI::Base.api_version = ShopifyAPI::ApiVersion::NullVersion
|
|
173
|
-
assert_equal
|
|
189
|
+
assert_equal(ShopifyAPI::ApiVersion::NullVersion, ShopifyAPI::Base.api_version)
|
|
174
190
|
end
|
|
175
191
|
|
|
176
192
|
test "#version_validation! does not raise is api_version is newer or equal to minimum supported version" do
|
|
177
193
|
ShopifyAPI::Base.api_version = '2020-01'
|
|
178
|
-
assert_nil
|
|
194
|
+
assert_nil(ShopifyAPI::Base::version_validation!('2020-01'))
|
|
179
195
|
end
|
|
180
196
|
|
|
181
197
|
test "#version_validation! raises NotImplemetedError if api_version is older than minimum supported version" do
|
|
182
198
|
ShopifyAPI::Base.api_version = '2019-10'
|
|
183
|
-
exception = assert_raises
|
|
199
|
+
exception = assert_raises(NotImplementedError) do
|
|
184
200
|
ShopifyAPI::Base::version_validation!('2020-01')
|
|
185
201
|
end
|
|
186
|
-
assert_equal
|
|
202
|
+
assert_equal('The minimum supported version is 2020-01.', exception.message)
|
|
187
203
|
end
|
|
188
204
|
|
|
189
|
-
|
|
190
205
|
def clear_header(header)
|
|
191
206
|
[ActiveResource::Base, ShopifyAPI::Base, ShopifyAPI::Product].each do |klass|
|
|
192
207
|
klass.headers.delete(header)
|