shopify_api 6.0.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -19
- data/CHANGELOG +11 -0
- data/Gemfile +1 -2
- data/Gemfile_ar41 +5 -0
- data/Gemfile_ar50 +5 -0
- data/Gemfile_ar51 +5 -0
- data/Gemfile_ar_master +0 -1
- data/README.md +116 -9
- data/RELEASING +2 -5
- data/lib/shopify_api.rb +4 -4
- data/lib/shopify_api/api_version.rb +116 -0
- data/lib/shopify_api/disable_prefix_check.rb +31 -0
- data/lib/shopify_api/limits.rb +5 -5
- data/lib/shopify_api/resources/access_scope.rb +6 -1
- data/lib/shopify_api/resources/asset.rb +15 -11
- data/lib/shopify_api/resources/base.rb +63 -1
- data/lib/shopify_api/resources/fulfillment_event.rb +1 -1
- data/lib/shopify_api/resources/graphql.rb +1 -1
- data/lib/shopify_api/resources/inventory_level.rb +2 -2
- data/lib/shopify_api/resources/location.rb +1 -1
- data/lib/shopify_api/resources/marketing_event.rb +2 -0
- data/lib/shopify_api/resources/payment.rb +1 -1
- data/lib/shopify_api/resources/refund.rb +4 -3
- data/lib/shopify_api/resources/shipping_rate.rb +1 -1
- data/lib/shopify_api/resources/shop.rb +4 -2
- data/lib/shopify_api/resources/smart_collection.rb +1 -1
- data/lib/shopify_api/session.rb +45 -16
- data/lib/shopify_api/version.rb +1 -1
- data/shopify_api.gemspec +3 -2
- data/test/access_scope_test.rb +23 -0
- data/test/api_version_test.rb +144 -0
- data/test/base_test.rb +75 -32
- data/test/detailed_log_subscriber_test.rb +51 -12
- data/test/fixtures/access_scopes.json +10 -0
- data/test/limits_test.rb +2 -2
- data/test/marketing_event_test.rb +1 -1
- data/test/recurring_application_charge_test.rb +3 -9
- data/test/session_test.rb +158 -32
- data/test/test_helper.rb +27 -11
- metadata +33 -21
- data/Gemfile_ar30 +0 -6
- data/Gemfile_ar31 +0 -6
- data/Gemfile_ar32 +0 -6
- data/Gemfile_ar40 +0 -6
- data/lib/active_resource/base_ext.rb +0 -21
- data/lib/active_resource/disable_prefix_check.rb +0 -36
- data/lib/active_resource/to_query.rb +0 -10
- data/lib/shopify_api/json_format.rb +0 -18
- data/lib/shopify_api/resources/o_auth.rb +0 -17
- data/lib/shopify_api/resources/ping/conversation.rb +0 -42
- data/lib/shopify_api/resources/ping/delivery_confirmation_details.rb +0 -10
- data/lib/shopify_api/resources/ping/message.rb +0 -8
- data/test/fixtures/o_auth_revoke.json +0 -5
- data/test/o_auth_test.rb +0 -8
- data/test/ping/conversation_test.rb +0 -71
- data/test/ping/message_test.rb +0 -23
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class ApiVersionTest < Test::Unit::TestCase
|
5
|
+
def teardown
|
6
|
+
super
|
7
|
+
ShopifyAPI::ApiVersion.clear_defined_versions
|
8
|
+
ShopifyAPI::ApiVersion.define_known_versions
|
9
|
+
end
|
10
|
+
|
11
|
+
test "unstable version creates url that start with /admin/api/unstable/" do
|
12
|
+
assert_equal(
|
13
|
+
"/admin/api/unstable/resource_path/id.json",
|
14
|
+
ShopifyAPI::ApiVersion::Unstable.new.construct_api_path("resource_path/id.json")
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
test "unstable version creates graphql url that start with /admin/api/unstable/" do
|
19
|
+
assert_equal(
|
20
|
+
"/admin/api/unstable/graphql.json",
|
21
|
+
ShopifyAPI::ApiVersion::Unstable.new.construct_graphql_path
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "coerce_to_version returns any version object given" do
|
26
|
+
version = ShopifyAPI::ApiVersion::Unstable.new
|
27
|
+
assert_same(version, ShopifyAPI::ApiVersion.coerce_to_version(version))
|
28
|
+
end
|
29
|
+
|
30
|
+
test "coerce_to_version converts a known version into a version object" do
|
31
|
+
versions = [
|
32
|
+
ShopifyAPI::ApiVersion::Unstable.new,
|
33
|
+
ShopifyAPI::ApiVersion::Release.new('2019-01'),
|
34
|
+
]
|
35
|
+
|
36
|
+
assert_equal(versions, [
|
37
|
+
ShopifyAPI::ApiVersion.coerce_to_version('unstable'),
|
38
|
+
ShopifyAPI::ApiVersion.coerce_to_version('2019-01'),
|
39
|
+
])
|
40
|
+
end
|
41
|
+
|
42
|
+
test "coerce_to_version raises when coercing a string that doesn't match a known version" do
|
43
|
+
assert_raises ShopifyAPI::ApiVersion::UnknownVersion do
|
44
|
+
ShopifyAPI::ApiVersion.coerce_to_version('made up version')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
test "additional defined versions will also be coerced" do
|
49
|
+
versions = [
|
50
|
+
TestApiVersion.new('my_name'),
|
51
|
+
TestApiVersion.new('other_name'),
|
52
|
+
]
|
53
|
+
|
54
|
+
versions.each do |version|
|
55
|
+
ShopifyAPI::ApiVersion.define_version(version)
|
56
|
+
end
|
57
|
+
|
58
|
+
assert_equal(versions, [
|
59
|
+
ShopifyAPI::ApiVersion.coerce_to_version('my_name'),
|
60
|
+
ShopifyAPI::ApiVersion.coerce_to_version('other_name'),
|
61
|
+
])
|
62
|
+
end
|
63
|
+
|
64
|
+
test 'allows a release version with the correct format format to be created' do
|
65
|
+
assert ShopifyAPI::ApiVersion::Release.new('2019-03')
|
66
|
+
end
|
67
|
+
|
68
|
+
test 'release versions must follow the format' do
|
69
|
+
assert_raises ShopifyAPI::ApiVersion::InvalidVersion do
|
70
|
+
assert ShopifyAPI::ApiVersion::Release.new('crazy-name')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
test 'release versions create a url that is /admin/api/<version_name>/' do
|
75
|
+
assert_equal(
|
76
|
+
'/admin/api/2022-03/shop.json',
|
77
|
+
ShopifyAPI::ApiVersion::Release.new('2022-03').construct_api_path('shop.json')
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'two versions with the same version number are equal' do
|
82
|
+
version_1 = ShopifyAPI::ApiVersion::Release.new('2018-09')
|
83
|
+
version_2 = ShopifyAPI::ApiVersion::Release.new('2018-09')
|
84
|
+
|
85
|
+
assert_equal version_2, version_1
|
86
|
+
end
|
87
|
+
|
88
|
+
test 'two versions with the different version numbers are not equal' do
|
89
|
+
version_1 = ShopifyAPI::ApiVersion::Release.new('2019-07')
|
90
|
+
version_2 = ShopifyAPI::ApiVersion::Release.new('2019-11')
|
91
|
+
|
92
|
+
refute_equal version_2, version_1
|
93
|
+
end
|
94
|
+
|
95
|
+
test 'release verions are stable' do
|
96
|
+
assert_predicate ShopifyAPI::ApiVersion::Release.new('2019-11'), :stable?
|
97
|
+
end
|
98
|
+
|
99
|
+
test 'no release version are not stable' do
|
100
|
+
refute_predicate ShopifyAPI::ApiVersion::Unstable.new, :stable?
|
101
|
+
end
|
102
|
+
|
103
|
+
test 'release versions are ordered by version number with unstable always being the newest' do
|
104
|
+
version_1 = ShopifyAPI::ApiVersion::Release.new('2017-11')
|
105
|
+
version_2 = ShopifyAPI::ApiVersion::Release.new('2019-11')
|
106
|
+
version_3 = ShopifyAPI::ApiVersion::Release.new('2039-01')
|
107
|
+
version_4 = ShopifyAPI::ApiVersion::Release.new('2039-02')
|
108
|
+
unstable = ShopifyAPI::ApiVersion::Unstable.new
|
109
|
+
|
110
|
+
assert_equal([
|
111
|
+
version_1,
|
112
|
+
version_2,
|
113
|
+
version_3,
|
114
|
+
version_4,
|
115
|
+
unstable,
|
116
|
+
], [
|
117
|
+
version_3,
|
118
|
+
version_1,
|
119
|
+
version_4,
|
120
|
+
unstable,
|
121
|
+
version_2,
|
122
|
+
].sort)
|
123
|
+
end
|
124
|
+
|
125
|
+
test 'latest_stable_version will return the version that is newest and stable' do
|
126
|
+
ShopifyAPI::ApiVersion.clear_defined_versions
|
127
|
+
ShopifyAPI::ApiVersion.define_version(ShopifyAPI::ApiVersion::Release.new('2017-11'))
|
128
|
+
ShopifyAPI::ApiVersion.define_version(ShopifyAPI::ApiVersion::Release.new('2019-11'))
|
129
|
+
ShopifyAPI::ApiVersion.define_version(ShopifyAPI::ApiVersion::Release.new('2039-01'))
|
130
|
+
ShopifyAPI::ApiVersion.define_version(ShopifyAPI::ApiVersion::Release.new('2039-02'))
|
131
|
+
ShopifyAPI::ApiVersion.define_version(ShopifyAPI::ApiVersion::Unstable.new)
|
132
|
+
|
133
|
+
assert_equal(
|
134
|
+
ShopifyAPI::ApiVersion::Release.new('2039-02'),
|
135
|
+
ShopifyAPI::ApiVersion.latest_stable_version
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
class TestApiVersion < ShopifyAPI::ApiVersion
|
140
|
+
def initialize(name)
|
141
|
+
@version_name = name
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/test/base_test.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
|
2
|
+
require "active_support/log_subscriber/test_helper"
|
3
3
|
|
4
4
|
class BaseTest < Test::Unit::TestCase
|
5
|
-
|
6
5
|
def setup
|
7
|
-
|
8
|
-
@
|
6
|
+
super
|
7
|
+
@session1 = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
|
8
|
+
@session2 = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: '2019-01')
|
9
9
|
end
|
10
10
|
|
11
11
|
def teardown
|
12
|
+
super
|
12
13
|
clear_header('X-Custom')
|
13
14
|
end
|
14
15
|
|
@@ -16,8 +17,8 @@ class BaseTest < Test::Unit::TestCase
|
|
16
17
|
ShopifyAPI::Base.activate_session @session1
|
17
18
|
|
18
19
|
assert_nil ActiveResource::Base.site
|
19
|
-
assert_equal 'https://shop1.myshopify.com
|
20
|
-
assert_equal 'https://shop1.myshopify.com
|
20
|
+
assert_equal 'https://shop1.myshopify.com', ShopifyAPI::Base.site.to_s
|
21
|
+
assert_equal 'https://shop1.myshopify.com', ShopifyAPI::Shop.site.to_s
|
21
22
|
|
22
23
|
assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token']
|
23
24
|
assert_equal 'token1', ShopifyAPI::Base.headers['X-Shopify-Access-Token']
|
@@ -56,8 +57,8 @@ class BaseTest < Test::Unit::TestCase
|
|
56
57
|
ShopifyAPI::Base.activate_session @session2
|
57
58
|
|
58
59
|
assert_nil ActiveResource::Base.site
|
59
|
-
assert_equal 'https://shop2.myshopify.com
|
60
|
-
assert_equal 'https://shop2.myshopify.com
|
60
|
+
assert_equal 'https://shop2.myshopify.com', ShopifyAPI::Base.site.to_s
|
61
|
+
assert_equal 'https://shop2.myshopify.com', ShopifyAPI::Shop.site.to_s
|
61
62
|
|
62
63
|
assert_nil ActiveResource::Base.headers['X-Shopify-Access-Token']
|
63
64
|
assert_equal 'token2', ShopifyAPI::Base.headers['X-Shopify-Access-Token']
|
@@ -73,7 +74,9 @@ class BaseTest < Test::Unit::TestCase
|
|
73
74
|
test "#delete should send custom headers with request" do
|
74
75
|
ShopifyAPI::Base.activate_session @session1
|
75
76
|
ShopifyAPI::Base.headers['X-Custom'] = 'abc'
|
76
|
-
ShopifyAPI::Base.connection
|
77
|
+
ShopifyAPI::Base.connection
|
78
|
+
.expects(:delete)
|
79
|
+
.with('/admin/api/2019-01/bases/1.json', has_entry('X-Custom', 'abc'))
|
77
80
|
ShopifyAPI::Base.delete "1"
|
78
81
|
end
|
79
82
|
|
@@ -86,35 +89,72 @@ class BaseTest < Test::Unit::TestCase
|
|
86
89
|
thread.join
|
87
90
|
end
|
88
91
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
assert_equal "the value", ShopifyAPI::Base.headers['X-Custom']
|
93
|
-
assert_equal "the value", ShopifyAPI::Product.headers['X-Custom']
|
94
|
-
end
|
92
|
+
test "prefix= will forward to resource when the value does not start with admin" do
|
93
|
+
session = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
|
94
|
+
ShopifyAPI::Base.activate_session(session)
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
TestResource.prefix = 'a/regular/path/'
|
97
|
+
|
98
|
+
assert_equal('/admin/api/2019-01/a/regular/path/', TestResource.prefix)
|
99
|
+
end
|
100
|
+
|
101
|
+
test "prefix= will raise an error if value starts with with /admin" do
|
102
|
+
assert_raises ArgumentError do
|
103
|
+
TestResource.prefix = '/admin/old/prefix/structure/'
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
104
|
-
|
105
|
-
|
107
|
+
test "#headers propagates changes to subclasses" do
|
108
|
+
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
109
|
+
assert_equal "the value", ShopifyAPI::Base.headers['X-Custom']
|
110
|
+
assert_equal "the value", ShopifyAPI::Product.headers['X-Custom']
|
111
|
+
end
|
112
|
+
|
113
|
+
test "#headers clears changes to subclasses" do
|
114
|
+
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
115
|
+
assert_equal "the value", ShopifyAPI::Product.headers['X-Custom']
|
116
|
+
ShopifyAPI::Base.headers['X-Custom'] = nil
|
117
|
+
assert_nil ShopifyAPI::Product.headers['X-Custom']
|
118
|
+
end
|
119
|
+
|
120
|
+
test "#headers set in the main thread affect spawned threads" do
|
121
|
+
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
122
|
+
Thread.new do
|
123
|
+
assert_equal "the value", ShopifyAPI::Base.headers['X-Custom']
|
124
|
+
end.join
|
125
|
+
end
|
126
|
+
|
127
|
+
test "#headers set in spawned threads do not affect the main thread" do
|
128
|
+
Thread.new do
|
106
129
|
ShopifyAPI::Base.headers['X-Custom'] = "the value"
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
130
|
+
end.join
|
131
|
+
assert_nil ShopifyAPI::Base.headers['X-Custom']
|
132
|
+
end
|
111
133
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
134
|
+
test "using a different version changes the url" do
|
135
|
+
release_2019_01 = ShopifyAPI::Session.new(domain: 'shop1.myshopify.com', token: 'token1', api_version: '2019-01')
|
136
|
+
unstable_version = ShopifyAPI::Session.new(domain: 'shop2.myshopify.com', token: 'token2', api_version: :unstable)
|
137
|
+
|
138
|
+
fake(
|
139
|
+
"shop",
|
140
|
+
url: "https://shop1.myshopify.com/admin/api/2019-01/shop.json",
|
141
|
+
method: :get,
|
142
|
+
status: 201,
|
143
|
+
body: '{ "shop": { "id": 1 } }'
|
144
|
+
)
|
145
|
+
fake(
|
146
|
+
"shop",
|
147
|
+
url: "https://shop2.myshopify.com/admin/api/unstable/shop.json",
|
148
|
+
method: :get,
|
149
|
+
status: 201,
|
150
|
+
body: '{ "shop": { "id": 2 } }'
|
151
|
+
)
|
152
|
+
|
153
|
+
ShopifyAPI::Base.activate_session(release_2019_01)
|
154
|
+
assert_equal 1, ShopifyAPI::Shop.current.id
|
155
|
+
|
156
|
+
ShopifyAPI::Base.activate_session(unstable_version)
|
157
|
+
assert_equal 2, ShopifyAPI::Shop.current.id
|
118
158
|
end
|
119
159
|
|
120
160
|
def clear_header(header)
|
@@ -122,4 +162,7 @@ class BaseTest < Test::Unit::TestCase
|
|
122
162
|
klass.headers.delete(header)
|
123
163
|
end
|
124
164
|
end
|
165
|
+
|
166
|
+
class TestResource < ShopifyAPI::Base
|
167
|
+
end
|
125
168
|
end
|
@@ -1,16 +1,29 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require "active_support/log_subscriber/test_helper"
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
class LogSubscriberTest < Test::Unit::TestCase
|
5
6
|
include ActiveSupport::LogSubscriber::TestHelper
|
6
7
|
|
8
|
+
attr_reader :request_headers
|
9
|
+
|
7
10
|
def setup
|
8
11
|
super
|
9
12
|
@page = { :page => { :id => 1, :title => 'Shopify API' } }.to_json
|
10
13
|
@ua_header = "\"User-Agent\"=>\"ShopifyAPI/#{ShopifyAPI::VERSION} ActiveResource/#{ActiveResource::VERSION::STRING} Ruby/#{RUBY_VERSION}\""
|
14
|
+
@request_headers = "Headers: {\"Accept\"=>\"application/json\", " \
|
15
|
+
"#{@ua_header}, \"X-Shopify-Access-Token\"=>\"access_token\"}"
|
16
|
+
|
17
|
+
ShopifyAPI::ApiVersion.define_version(ShopifyAPI::ApiVersion::Release.new('2019-01'))
|
11
18
|
|
12
19
|
ShopifyAPI::Base.clear_session
|
13
|
-
|
20
|
+
session = ShopifyAPI::Session.new(
|
21
|
+
domain: "https://this-is-my-test-shop.myshopify.com",
|
22
|
+
token: "access_token",
|
23
|
+
api_version: '2019-01'
|
24
|
+
)
|
25
|
+
|
26
|
+
ShopifyAPI::Base.activate_session(session)
|
14
27
|
|
15
28
|
ActiveResource::LogSubscriber.attach_to :active_resource
|
16
29
|
ActiveResource::DetailedLogSubscriber.attach_to :active_resource_detailed
|
@@ -25,11 +38,18 @@ class LogSubscriberTest < Test::Unit::TestCase
|
|
25
38
|
|
26
39
|
ShopifyAPI::Page.find(1)
|
27
40
|
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
|
31
|
-
|
32
|
-
|
41
|
+
assert_equal(4, @logger.logged(:info).size)
|
42
|
+
assert_equal(
|
43
|
+
"GET https://this-is-my-test-shop.myshopify.com:443/admin/api/2019-01/pages/1.json",
|
44
|
+
@logger.logged(:info)[0]
|
45
|
+
)
|
46
|
+
assert_match(/\-\-\> 200/, @logger.logged(:info)[1])
|
47
|
+
assert_equal(request_headers, @logger.logged(:info)[2])
|
48
|
+
assert_match(
|
49
|
+
%r{(Response:\n\{\"page\"\:\{\"id\"\:1,\"title\"\:\"Shopify API\"\}\})|
|
50
|
+
(Response:\n\{\"page\"\:\{\"title\"\:\"Shopify API\",\"id\"\:1\}\})},
|
51
|
+
@logger.logged(:info)[3]
|
52
|
+
)
|
33
53
|
end
|
34
54
|
|
35
55
|
test "logging on #find with an error" do
|
@@ -39,11 +59,27 @@ class LogSubscriberTest < Test::Unit::TestCase
|
|
39
59
|
ShopifyAPI::Page.find(2)
|
40
60
|
end
|
41
61
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
62
|
+
if ar_version_before?('5.1.0')
|
63
|
+
assert_equal(4, @logger.logged(:info).size)
|
64
|
+
assert_equal(
|
65
|
+
"GET https://this-is-my-test-shop.myshopify.com:443/admin/api/2019-01/pages/2.json",
|
66
|
+
@logger.logged(:info)[0]
|
67
|
+
)
|
68
|
+
assert_match(/\-\-\> 404/, @logger.logged(:info)[1])
|
69
|
+
assert_equal(request_headers, @logger.logged(:info)[2])
|
70
|
+
assert_equal("Response:", @logger.logged(:info)[3])
|
71
|
+
else
|
72
|
+
assert_equal(2, @logger.logged(:error).size)
|
73
|
+
assert_equal(
|
74
|
+
"GET https://this-is-my-test-shop.myshopify.com:443/admin/api/2019-01/pages/2.json",
|
75
|
+
@logger.logged(:error)[0]
|
76
|
+
)
|
77
|
+
assert_match(/\-\-\> 404/, @logger.logged(:error)[1])
|
78
|
+
|
79
|
+
assert_equal(2, @logger.logged(:info).size)
|
80
|
+
assert_equal(request_headers, @logger.logged(:info)[0])
|
81
|
+
assert_equal("Response:", @logger.logged(:info)[1])
|
82
|
+
end
|
47
83
|
end
|
48
84
|
|
49
85
|
test "warns when the server responds with a x-shopify-api-deprecated-reason header" do
|
@@ -58,7 +94,10 @@ class LogSubscriberTest < Test::Unit::TestCase
|
|
58
94
|
|
59
95
|
assert_equal 1, @logger.logged(:warn).size
|
60
96
|
|
61
|
-
assert_match
|
97
|
+
assert_match(
|
98
|
+
%r{\[DEPRECATED\] ShopifyAPI made a call to GET /admin/api/2019-01/pages/1.json},
|
99
|
+
@logger.logged(:warn).first
|
100
|
+
)
|
62
101
|
assert_match(
|
63
102
|
%r{See https:\/\/help.shopify.com\/en\/api\/getting-started\/api-deprecations for more details.},
|
64
103
|
@logger.logged(:warn).first
|
data/test/limits_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class LimitsTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
super
|
6
|
-
@header_hash = {'
|
6
|
+
@header_hash = { 'X-Shopify-Shop-Api-Call-Limit' => '100/300' }
|
7
7
|
ShopifyAPI::Base.connection.expects(:response).at_least(0).returns(@header_hash)
|
8
8
|
end
|
9
9
|
|
@@ -22,7 +22,7 @@ class LimitsTest < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
should "flag maxed out credits" do
|
24
24
|
assert !ShopifyAPI.maxed?
|
25
|
-
@header_hash = {'
|
25
|
+
@header_hash = { 'X-Shopify-Shop-Api-Call-Limit' => '299/300' }
|
26
26
|
ShopifyAPI::Base.connection.expects(:response).at_least(1).returns(@header_hash)
|
27
27
|
assert ShopifyAPI.maxed?
|
28
28
|
end
|
@@ -43,7 +43,7 @@ class MarketingEventTest < Test::Unit::TestCase
|
|
43
43
|
|
44
44
|
def test_count_marketing_events
|
45
45
|
fake "marketing_events/count", :method => :get, :body => '{"count": 2}'
|
46
|
-
marketing_events_count = ShopifyAPI::MarketingEvent.
|
46
|
+
marketing_events_count = ShopifyAPI::MarketingEvent.count
|
47
47
|
assert_equal 2, marketing_events_count
|
48
48
|
end
|
49
49
|
|
@@ -136,14 +136,8 @@ class RecurringApplicationChargeTest < Test::Unit::TestCase
|
|
136
136
|
def test_recurring_application_charge_not_found_error
|
137
137
|
fake "recurring_application_charges", body: '{"errors":"Not Found"}', status: 404
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
else
|
143
|
-
assert_equal nil, all_application_charges
|
144
|
-
end
|
145
|
-
|
146
|
-
assert_equal nil, ShopifyAPI::RecurringApplicationCharge.current
|
147
|
-
assert_equal [], ShopifyAPI::RecurringApplicationCharge.pending
|
139
|
+
assert_equal(nil, ShopifyAPI::RecurringApplicationCharge.all)
|
140
|
+
assert_equal(nil, ShopifyAPI::RecurringApplicationCharge.current)
|
141
|
+
assert_equal([], ShopifyAPI::RecurringApplicationCharge.pending)
|
148
142
|
end
|
149
143
|
end
|