shopify_api 6.0.0 → 7.0.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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -19
  3. data/CHANGELOG +11 -0
  4. data/Gemfile +1 -2
  5. data/Gemfile_ar41 +5 -0
  6. data/Gemfile_ar50 +5 -0
  7. data/Gemfile_ar51 +5 -0
  8. data/Gemfile_ar_master +0 -1
  9. data/README.md +116 -9
  10. data/RELEASING +2 -5
  11. data/lib/shopify_api.rb +4 -4
  12. data/lib/shopify_api/api_version.rb +116 -0
  13. data/lib/shopify_api/disable_prefix_check.rb +31 -0
  14. data/lib/shopify_api/limits.rb +5 -5
  15. data/lib/shopify_api/resources/access_scope.rb +6 -1
  16. data/lib/shopify_api/resources/asset.rb +15 -11
  17. data/lib/shopify_api/resources/base.rb +63 -1
  18. data/lib/shopify_api/resources/fulfillment_event.rb +1 -1
  19. data/lib/shopify_api/resources/graphql.rb +1 -1
  20. data/lib/shopify_api/resources/inventory_level.rb +2 -2
  21. data/lib/shopify_api/resources/location.rb +1 -1
  22. data/lib/shopify_api/resources/marketing_event.rb +2 -0
  23. data/lib/shopify_api/resources/payment.rb +1 -1
  24. data/lib/shopify_api/resources/refund.rb +4 -3
  25. data/lib/shopify_api/resources/shipping_rate.rb +1 -1
  26. data/lib/shopify_api/resources/shop.rb +4 -2
  27. data/lib/shopify_api/resources/smart_collection.rb +1 -1
  28. data/lib/shopify_api/session.rb +45 -16
  29. data/lib/shopify_api/version.rb +1 -1
  30. data/shopify_api.gemspec +3 -2
  31. data/test/access_scope_test.rb +23 -0
  32. data/test/api_version_test.rb +144 -0
  33. data/test/base_test.rb +75 -32
  34. data/test/detailed_log_subscriber_test.rb +51 -12
  35. data/test/fixtures/access_scopes.json +10 -0
  36. data/test/limits_test.rb +2 -2
  37. data/test/marketing_event_test.rb +1 -1
  38. data/test/recurring_application_charge_test.rb +3 -9
  39. data/test/session_test.rb +158 -32
  40. data/test/test_helper.rb +27 -11
  41. metadata +33 -21
  42. data/Gemfile_ar30 +0 -6
  43. data/Gemfile_ar31 +0 -6
  44. data/Gemfile_ar32 +0 -6
  45. data/Gemfile_ar40 +0 -6
  46. data/lib/active_resource/base_ext.rb +0 -21
  47. data/lib/active_resource/disable_prefix_check.rb +0 -36
  48. data/lib/active_resource/to_query.rb +0 -10
  49. data/lib/shopify_api/json_format.rb +0 -18
  50. data/lib/shopify_api/resources/o_auth.rb +0 -17
  51. data/lib/shopify_api/resources/ping/conversation.rb +0 -42
  52. data/lib/shopify_api/resources/ping/delivery_confirmation_details.rb +0 -10
  53. data/lib/shopify_api/resources/ping/message.rb +0 -8
  54. data/test/fixtures/o_auth_revoke.json +0 -5
  55. data/test/o_auth_test.rb +0 -8
  56. data/test/ping/conversation_test.rb +0 -71
  57. 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
@@ -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
- @session1 = ShopifyAPI::Session.new('shop1.myshopify.com', 'token1')
8
- @session2 = ShopifyAPI::Session.new('shop2.myshopify.com', 'token2')
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/admin', ShopifyAPI::Base.site.to_s
20
- assert_equal 'https://shop1.myshopify.com/admin', ShopifyAPI::Shop.site.to_s
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/admin', ShopifyAPI::Base.site.to_s
60
- assert_equal 'https://shop2.myshopify.com/admin', ShopifyAPI::Shop.site.to_s
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.expects(:delete).with('/admin/bases/1.json', has_entry('X-Custom', 'abc'))
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
- if ActiveResource::VERSION::MAJOR >= 4
90
- test "#headers propagates changes to subclasses" do
91
- ShopifyAPI::Base.headers['X-Custom'] = "the value"
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
- test "#headers clears changes to subclasses" do
97
- ShopifyAPI::Base.headers['X-Custom'] = "the value"
98
- assert_equal "the value", ShopifyAPI::Product.headers['X-Custom']
99
- ShopifyAPI::Base.headers['X-Custom'] = nil
100
- assert_nil ShopifyAPI::Product.headers['X-Custom']
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
- if ActiveResource::VERSION::MAJOR >= 5 || (ActiveResource::VERSION::MAJOR >= 4 && ActiveResource::VERSION::PRE == "threadsafe")
105
- test "#headers set in the main thread affect spawned threads" do
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
- Thread.new do
108
- assert_equal "the value", ShopifyAPI::Base.headers['X-Custom']
109
- end.join
110
- end
130
+ end.join
131
+ assert_nil ShopifyAPI::Base.headers['X-Custom']
132
+ end
111
133
 
112
- test "#headers set in spawned threads do not affect the main thread" do
113
- Thread.new do
114
- ShopifyAPI::Base.headers['X-Custom'] = "the value"
115
- end.join
116
- assert_nil ShopifyAPI::Base.headers['X-Custom']
117
- end
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
- ShopifyAPI::Base.site = "https://this-is-my-test-shop.myshopify.com/admin"
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 4, @logger.logged(:info).size
29
- assert_equal "GET https://this-is-my-test-shop.myshopify.com:443/admin/pages/1.json", @logger.logged(:info)[0]
30
- assert_match /\-\-\> 200/, @logger.logged(:info)[1]
31
- assert_equal "Headers: {\"Accept\"=>\"application/json\", #{@ua_header}}", @logger.logged(:info)[2]
32
- assert_match /Response:\n\{\"page\"\:\{((\"id\"\:1)|(\"title\"\:\"Shopify API\")),((\"id\"\:1)|(\"title\"\:\"Shopify API\"))\}\}/, @logger.logged(:info)[3]
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
- assert_equal 4, @logger.logged(:info).size
43
- assert_equal "GET https://this-is-my-test-shop.myshopify.com:443/admin/pages/2.json", @logger.logged(:info)[0]
44
- assert_match /\-\-\> 404/, @logger.logged(:info)[1]
45
- assert_equal "Headers: {\"Accept\"=>\"application/json\", #{@ua_header}}", @logger.logged(:info)[2]
46
- assert_equal "Response:", @logger.logged(:info)[3]
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 %r{\[DEPRECATED\] ShopifyAPI made a call to GET \/admin\/pages\/1.json}, @logger.logged(:warn).first
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
@@ -0,0 +1,10 @@
1
+ {
2
+ "access_scopes": [
3
+ {
4
+ "handle": "write_product_listings"
5
+ },
6
+ {
7
+ "handle": "read_shipping"
8
+ }
9
+ ]
10
+ }
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class LimitsTest < Test::Unit::TestCase
4
4
  def setup
5
5
  super
6
- @header_hash = {'http_x_shopify_shop_api_call_limit' => '100/300'}
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 = {'http_x_shopify_shop_api_call_limit' => '299/300'}
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.get(:count)
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
- all_application_charges = ShopifyAPI::RecurringApplicationCharge.all
140
- if ActiveResource::VERSION::MAJOR >= 5 || (ActiveResource::VERSION::MAJOR == 4 && ActiveResource::VERSION::MINOR >= 2)
141
- assert_equal [], all_application_charges
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