shopify_api 4.0.3 → 4.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd5fe880e2969fad40ac19852da5eb801ca3e4af
4
- data.tar.gz: ae6b8c7e61139171bbf02cb5ac14552ea3c4319e
3
+ metadata.gz: 23955d9a8ee5d523632bcb12220cb5c366516346
4
+ data.tar.gz: 0c2f364c901d280de601677340f045c7e77910c1
5
5
  SHA512:
6
- metadata.gz: 3e40036c3bfb41301aee1c74093cf991435b85764cfea3dcd828195a6cd404c74838cadefc1c84af4b3d03c6df92f3cd4957d84ed05a212e299c5608cf428edc
7
- data.tar.gz: 13d1f0077ecad5dc2c45a680f066e4590d8fbb0c5e53040ce4e8e4ea5d837415e4ff63728e84fd246424a8a6a053fb95b7e79034037ca5c057d61b7d398cd35c
6
+ metadata.gz: 7f749d13957df809a2b68814b66e9db6dee6144da7b85e25d7d6c42c03c0bffff05c9427b57b58a92a8410ee97009a8d965f67c42d7441a5a878f55e3f07e541
7
+ data.tar.gz: e3e90a739fbea49071641aa89d677f63d3e9aed7ef6760218a8f26761fb5e468300a87bee1c905adf7adbf8459e27c5fbdf287fb32639f6aaf7bc8a11f580dfb
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == Version 4.0.4
2
+
3
+ * Fixed truthiness for order cancellations. Requests are now sent in the request body and as JSON
4
+
1
5
  == Version 4.0.3
2
6
 
3
7
  * Fixed hmac signature validation for params with delimiters (`&`, `=` or `%`)
@@ -7,7 +7,7 @@ module ShopifyAPI
7
7
  def open; load_attributes_from_response(post(:open, {}, only_id)); end
8
8
 
9
9
  def cancel(options = {})
10
- load_attributes_from_response(post(:cancel, options, only_id))
10
+ load_attributes_from_response(post(:cancel, {}, options.to_json))
11
11
  end
12
12
 
13
13
  def transactions
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "4.0.3"
2
+ VERSION = "4.0.4"
3
3
  end
@@ -36,7 +36,7 @@ class LogSubscriberTest < Test::Unit::TestCase
36
36
  test "logging on #find with an error" do
37
37
  fake "pages/2", :method => :get, :body => nil, :status => 404
38
38
 
39
- assert_raise ActiveResource::ResourceNotFound do
39
+ assert_raises ActiveResource::ResourceNotFound do
40
40
  ShopifyAPI::Page.find(2)
41
41
  end
42
42
 
data/test/limits_test.rb CHANGED
@@ -30,7 +30,7 @@ class LimitsTest < Test::Unit::TestCase
30
30
  should "raise error when header doesn't exist" do
31
31
  @header_hash = {}
32
32
  ShopifyAPI::Base.connection.expects(:response).at_least(1).returns(@header_hash)
33
- assert_raise ShopifyAPI::Limits::LimitUnavailable do
33
+ assert_raises ShopifyAPI::Limits::LimitUnavailable do
34
34
  ShopifyAPI.credit_left
35
35
  end
36
36
  end
data/test/order_test.rb CHANGED
@@ -35,5 +35,13 @@ class OrderTest < Test::Unit::TestCase
35
35
  order = ShopifyAPI::Order.find(450789469)
36
36
  assert order.destroy
37
37
  end
38
+
39
+ test "cancel an order with params" do
40
+ fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
41
+ fake 'orders/450789469/cancel', :method => :post, :body => load_fixture('order')
42
+ order = ShopifyAPI::Order.find(450789469)
43
+ order.cancel(email: false, restock: true)
44
+ assert_request_body({'email' => false, 'restock' => true}.to_json)
45
+ end
38
46
  end
39
47
 
data/test/session_test.rb CHANGED
@@ -2,198 +2,205 @@ require 'test_helper'
2
2
 
3
3
  class SessionTest < Test::Unit::TestCase
4
4
 
5
- context "Session" do
6
- should "not be valid without a url" do
7
- session = ShopifyAPI::Session.new(nil, "any-token")
8
- assert_not session.valid?
9
- end
5
+ def setup
6
+ ShopifyAPI::Session.secret = 'secret'
7
+ end
10
8
 
11
- should "not be valid without token" do
12
- session = ShopifyAPI::Session.new("testshop.myshopify.com")
13
- assert_not session.valid?
14
- end
9
+ test "not be valid without a url" do
10
+ session = ShopifyAPI::Session.new(nil, "any-token")
11
+ assert_not session.valid?
12
+ end
13
+
14
+ test "not be valid without token" do
15
+ session = ShopifyAPI::Session.new("testshop.myshopify.com")
16
+ assert_not session.valid?
17
+ end
15
18
 
16
- should "be valid with any token and any url" do
19
+ test "be valid with any token and any url" do
20
+ session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
21
+ assert session.valid?
22
+ end
23
+
24
+ test "not raise error without params" do
25
+ assert_nothing_raised do
17
26
  session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
18
- assert session.valid?
19
27
  end
28
+ end
20
29
 
21
- should "ignore everything but the subdomain in the shop" do
22
- assert_equal "https://testshop.myshopify.com/admin", ShopifyAPI::Session.new("http://user:pass@testshop.notshopify.net/path", "any-token").site
23
- end
30
+ test "ignore everything but the subdomain in the shop" do
31
+ assert_equal "https://testshop.myshopify.com/admin", ShopifyAPI::Session.new("http://user:pass@testshop.notshopify.net/path", "any-token").site
32
+ end
24
33
 
25
- should "append the myshopify domain if not given" do
26
- assert_equal "https://testshop.myshopify.com/admin", ShopifyAPI::Session.new("testshop", "any-token").site
27
- end
34
+ test "append the myshopify domain if not given" do
35
+ assert_equal "https://testshop.myshopify.com/admin", ShopifyAPI::Session.new("testshop", "any-token").site
36
+ end
28
37
 
29
- should "not raise error without params" do
30
- assert_nothing_raised do
31
- session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
32
- end
38
+ test "not raise error without params" do
39
+ assert_nothing_raised do
40
+ session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
33
41
  end
42
+ end
34
43
 
35
- should "raise error if params passed but signature omitted" do
36
- assert_raises(ShopifyAPI::ValidationException) do
37
- session = ShopifyAPI::Session.new("testshop.myshopify.com")
38
- session.request_token({'code' => 'any-code'})
39
- end
44
+ test "raise error if params passed but signature omitted" do
45
+ assert_raises(ShopifyAPI::ValidationException) do
46
+ session = ShopifyAPI::Session.new("testshop.myshopify.com")
47
+ session.request_token({'code' => 'any-code'})
40
48
  end
49
+ end
41
50
 
42
- should "setup api_key and secret for all sessions" do
43
- ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
44
- assert_equal "My test key", ShopifyAPI::Session.api_key
45
- assert_equal "My test secret", ShopifyAPI::Session.secret
46
- end
51
+ test "setup api_key and secret for all sessions" do
52
+ ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
53
+ assert_equal "My test key", ShopifyAPI::Session.api_key
54
+ assert_equal "My test secret", ShopifyAPI::Session.secret
55
+ end
47
56
 
48
- should "use 'https' protocol by default for all sessions" do
49
- assert_equal 'https', ShopifyAPI::Session.protocol
50
- end
57
+ test "use 'https' protocol by default for all sessions" do
58
+ assert_equal 'https', ShopifyAPI::Session.protocol
59
+ end
51
60
 
52
- should "#temp reset ShopifyAPI::Base.site to original value" do
61
+ test "#temp reset ShopifyAPI::Base.site to original value" do
53
62
 
54
- ShopifyAPI::Session.setup(:api_key => "key", :secret => "secret")
55
- session1 = ShopifyAPI::Session.new('fakeshop.myshopify.com', 'token1')
56
- ShopifyAPI::Base.activate_session(session1)
63
+ ShopifyAPI::Session.setup(:api_key => "key", :secret => "secret")
64
+ session1 = ShopifyAPI::Session.new('fakeshop.myshopify.com', 'token1')
65
+ ShopifyAPI::Base.activate_session(session1)
57
66
 
58
- ShopifyAPI::Session.temp("testshop.myshopify.com", "any-token") {
59
- @assigned_site = ShopifyAPI::Base.site
60
- }
61
- assert_equal 'https://testshop.myshopify.com/admin', @assigned_site.to_s
62
- assert_equal 'https://fakeshop.myshopify.com/admin', ShopifyAPI::Base.site.to_s
63
- end
67
+ ShopifyAPI::Session.temp("testshop.myshopify.com", "any-token") {
68
+ @assigned_site = ShopifyAPI::Base.site
69
+ }
70
+ assert_equal 'https://testshop.myshopify.com/admin', @assigned_site.to_s
71
+ assert_equal 'https://fakeshop.myshopify.com/admin', ShopifyAPI::Base.site.to_s
72
+ end
64
73
 
65
- should "create_permission_url returns correct url with single scope no redirect uri" do
66
- ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
67
- session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
68
- scope = ["write_products"]
69
- permission_url = session.create_permission_url(scope)
70
- assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products", permission_url
71
- end
74
+ test "create_permission_url returns correct url with single scope no redirect uri" do
75
+ ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
76
+ session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
77
+ scope = ["write_products"]
78
+ permission_url = session.create_permission_url(scope)
79
+ assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products", permission_url
80
+ end
72
81
 
73
- should "create_permission_url returns correct url with single scope and redirect uri" do
74
- ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
75
- session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
76
- scope = ["write_products"]
77
- permission_url = session.create_permission_url(scope, "http://my_redirect_uri.com")
78
- assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products&redirect_uri=http://my_redirect_uri.com", permission_url
79
- end
82
+ test "create_permission_url returns correct url with single scope and redirect uri" do
83
+ ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
84
+ session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
85
+ scope = ["write_products"]
86
+ permission_url = session.create_permission_url(scope, "http://my_redirect_uri.com")
87
+ assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products&redirect_uri=http://my_redirect_uri.com", permission_url
88
+ end
80
89
 
81
- should "create_permission_url returns correct url with dual scope no redirect uri" do
82
- ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
83
- session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
84
- scope = ["write_products","write_customers"]
85
- permission_url = session.create_permission_url(scope)
86
- assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products,write_customers", permission_url
87
- end
90
+ test "create_permission_url returns correct url with dual scope no redirect uri" do
91
+ ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
92
+ session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
93
+ scope = ["write_products","write_customers"]
94
+ permission_url = session.create_permission_url(scope)
95
+ assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products,write_customers", permission_url
96
+ end
88
97
 
89
- should "create_permission_url returns correct url with no scope no redirect uri" do
90
- ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
91
- session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
92
- scope = []
93
- permission_url = session.create_permission_url(scope)
94
- assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=", permission_url
95
- end
98
+ test "create_permission_url returns correct url with no scope no redirect uri" do
99
+ ShopifyAPI::Session.setup(:api_key => "My_test_key", :secret => "My test secret")
100
+ session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
101
+ scope = []
102
+ permission_url = session.create_permission_url(scope)
103
+ assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=", permission_url
104
+ end
96
105
 
97
- should "raise exception if code invalid in request token" do
98
- ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
99
- session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
100
- fake nil, :url => 'https://localhost.myshopify.com/admin/oauth/access_token',:method => :post, :status => 404, :body => '{"error" : "invalid_request"}'
101
- assert_raises(ShopifyAPI::ValidationException) do
102
- session.request_token(params={:code => "bad-code"})
103
- end
104
- assert_equal false, session.valid?
106
+ test "raise exception if code invalid in request token" do
107
+ ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
108
+ session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
109
+ fake nil, :url => 'https://localhost.myshopify.com/admin/oauth/access_token',:method => :post, :status => 404, :body => '{"error" : "invalid_request"}'
110
+ assert_raises(ShopifyAPI::ValidationException) do
111
+ session.request_token(params={:code => "bad-code"})
105
112
  end
113
+ assert_equal false, session.valid?
114
+ end
106
115
 
107
- should "myshopify_domain supports non-standard ports" do
108
- begin
109
- ShopifyAPI::Session.setup(:api_key => "key", :secret => "secret", :myshopify_domain => 'localhost', port: '3000')
110
-
111
- session = ShopifyAPI::Session.new('fakeshop.localhost:3000', 'token1')
112
- ShopifyAPI::Base.activate_session(session)
113
- assert_equal 'https://fakeshop.localhost:3000/admin', ShopifyAPI::Base.site.to_s
114
-
115
- session = ShopifyAPI::Session.new('fakeshop', 'token1')
116
- ShopifyAPI::Base.activate_session(session)
117
- assert_equal 'https://fakeshop.localhost:3000/admin', ShopifyAPI::Base.site.to_s
118
- ensure
119
- ShopifyAPI::Session.myshopify_domain = "myshopify.com"
120
- ShopifyAPI::Session.port = nil
121
- end
122
- end
116
+ test "#temp reset ShopifyAPI::Base.site to original value when using a non-standard port" do
117
+ ShopifyAPI::Session.setup(:api_key => "key", :secret => "secret")
118
+ session1 = ShopifyAPI::Session.new('fakeshop.myshopify.com:3000', 'token1')
119
+ ShopifyAPI::Base.activate_session(session1)
120
+ end
123
121
 
124
- should "return site for session" do
125
- session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
126
- assert_equal "https://testshop.myshopify.com/admin", session.site
127
- end
122
+ test "myshopify_domain supports non-standard ports" do
123
+ begin
124
+ ShopifyAPI::Session.setup(:api_key => "key", :secret => "secret", :myshopify_domain => 'localhost', port: '3000')
125
+ session = ShopifyAPI::Session.new('fakeshop.localhost:3000', 'token1')
126
+ ShopifyAPI::Base.activate_session(session)
127
+ assert_equal 'https://fakeshop.localhost:3000/admin', ShopifyAPI::Base.site.to_s
128
128
 
129
- should "return_token_if_signature_is_valid" do
130
- ShopifyAPI::Session.secret = 'secret'
131
- params = {:code => 'any-code', :timestamp => Time.now}
132
- sorted_params = make_sorted_params(params)
133
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
134
- fake nil, :url => 'https://testshop.myshopify.com/admin/oauth/access_token',:method => :post, :body => '{"access_token" : "any-token"}'
135
- session = ShopifyAPI::Session.new("testshop.myshopify.com")
136
- token = session.request_token(params.merge(:hmac => signature))
137
- assert_equal "any-token", token
129
+ session = ShopifyAPI::Session.new('fakeshop', 'token1')
130
+ ShopifyAPI::Base.activate_session(session)
131
+ assert_equal 'https://fakeshop.localhost:3000/admin', ShopifyAPI::Base.site.to_s
132
+ ensure
133
+ ShopifyAPI::Session.myshopify_domain = "myshopify.com"
134
+ ShopifyAPI::Session.port = nil
138
135
  end
136
+ end
139
137
 
140
- should "raise error if signature does not match expected" do
141
- ShopifyAPI::Session.secret = 'secret'
142
- params = {:code => "any-code", :timestamp => Time.now}
143
- sorted_params = make_sorted_params(params)
144
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
145
- params[:foo] = 'world'
146
- assert_raises(ShopifyAPI::ValidationException) do
147
- session = ShopifyAPI::Session.new("testshop.myshopify.com")
148
- session.request_token(params.merge(:hmac => signature))
149
- end
150
- end
138
+ test "return site for session" do
139
+ session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
140
+ assert_equal "https://testshop.myshopify.com/admin", session.site
141
+ end
151
142
 
152
- should "raise error if timestamp is too old" do
153
- ShopifyAPI::Session.secret = 'secret'
154
- params = {:code => "any-code", :timestamp => Time.now - 2.days}
155
- sorted_params = make_sorted_params(params)
156
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
157
- params[:foo] = 'world'
158
- assert_raises(ShopifyAPI::ValidationException) do
159
- session = ShopifyAPI::Session.new("testshop.myshopify.com")
160
- session.request_token(params.merge(:hmac => signature))
161
- end
162
- end
143
+ test "return_token_if_signature_is_valid" do
144
+ params = {:code => 'any-code', :timestamp => Time.now}
145
+ sorted_params = make_sorted_params(params)
146
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
147
+ fake nil, :url => 'https://testshop.myshopify.com/admin/oauth/access_token',:method => :post, :body => '{"access_token" : "any-token"}'
148
+ session = ShopifyAPI::Session.new("testshop.myshopify.com")
149
+ token = session.request_token(params.merge(:hmac => signature))
150
+ assert_equal "any-token", token
151
+ end
163
152
 
164
- should "return true when the signature is valid and the keys of params are strings" do
165
- now = Time.now
166
- params = {"code" => "any-code", "timestamp" => now}
167
- sorted_params = make_sorted_params(params)
168
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
169
- params = {"code" => "any-code", "timestamp" => now, "hmac" => signature}
153
+ test "raise error if signature does not match expected" do
154
+ params = {:code => "any-code", :timestamp => Time.now}
155
+ sorted_params = make_sorted_params(params)
156
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
157
+ params[:foo] = 'world'
158
+ assert_raises(ShopifyAPI::ValidationException) do
159
+ session = ShopifyAPI::Session.new("testshop.myshopify.com")
160
+ session.request_token(params.merge(:hmac => signature))
161
+ end
162
+ end
170
163
 
171
- assert_equal true, ShopifyAPI::Session.validate_signature(params)
164
+ test "raise error if timestamp is too old" do
165
+ params = {:code => "any-code", :timestamp => Time.now - 2.days}
166
+ sorted_params = make_sorted_params(params)
167
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
168
+ params[:foo] = 'world'
169
+ assert_raises(ShopifyAPI::ValidationException) do
170
+ session = ShopifyAPI::Session.new("testshop.myshopify.com")
171
+ session.request_token(params.merge(:hmac => signature))
172
172
  end
173
+ end
173
174
 
174
- should "return true when validating signature of params with ampersand and equal sign characters" do
175
- ShopifyAPI::Session.secret = 'secret'
176
- params = {'a' => '1&b=2', 'c=3&d' => '4'}
177
- to_sign = "a=1%26b=2&c%3D3%26d=4"
178
- params['hmac'] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ShopifyAPI::Session.secret, to_sign)
175
+ test "return true when the signature is valid and the keys of params are strings" do
176
+ now = Time.now
177
+ params = {"code" => "any-code", "timestamp" => now}
178
+ sorted_params = make_sorted_params(params)
179
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
180
+ params = {"code" => "any-code", "timestamp" => now, "hmac" => signature}
181
+ end
179
182
 
180
- assert_equal true, ShopifyAPI::Session.validate_signature(params)
181
- end
183
+ test "return true when validating signature of params with ampersand and equal sign characters" do
184
+ ShopifyAPI::Session.secret = 'secret'
185
+ params = {'a' => '1&b=2', 'c=3&d' => '4'}
186
+ to_sign = "a=1%26b=2&c%3D3%26d=4"
187
+ params['hmac'] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ShopifyAPI::Session.secret, to_sign)
182
188
 
183
- test "return true when validating signature of params with percent sign characters" do
184
- ShopifyAPI::Session.secret = 'secret'
185
- params = {'a%3D1%26b' => '2%26c%3D3'}
186
- to_sign = "a%253D1%2526b=2%2526c%253D3"
187
- params['hmac'] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ShopifyAPI::Session.secret, to_sign)
189
+ assert_equal true, ShopifyAPI::Session.validate_signature(params)
190
+ end
188
191
 
189
- assert_equal true, ShopifyAPI::Session.validate_signature(params)
190
- end
192
+ test "return true when validating signature of params with percent sign characters" do
193
+ ShopifyAPI::Session.secret = 'secret'
194
+ params = {'a%3D1%26b' => '2%26c%3D3'}
195
+ to_sign = "a%253D1%2526b=2%2526c%253D3"
196
+ params['hmac'] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ShopifyAPI::Session.secret, to_sign)
191
197
 
192
- private
198
+ assert_equal true, ShopifyAPI::Session.validate_signature(params)
199
+ end
193
200
 
194
- def make_sorted_params(params)
195
- sorted_params = params.with_indifferent_access.except(:signature, :hmac, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join('&')
196
- end
201
+ private
197
202
 
203
+ def make_sorted_params(params)
204
+ sorted_params = params.with_indifferent_access.except(:signature, :hmac, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join('&')
198
205
  end
199
206
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require 'fakeweb'
4
4
  require 'mocha/setup'
5
5
 
@@ -10,8 +10,12 @@ require 'shopify_api'
10
10
  FakeWeb.allow_net_connect = false
11
11
 
12
12
  # setup ShopifyAPI with fake api_key and secret
13
+ module Test
14
+ module Unit
15
+ end
16
+ end
13
17
 
14
- class Test::Unit::TestCase
18
+ class Test::Unit::TestCase < Minitest::Unit::TestCase
15
19
  def self.test(string, &block)
16
20
  define_method("test:#{string}", &block)
17
21
  end
@@ -46,13 +50,29 @@ class Test::Unit::TestCase
46
50
 
47
51
  # Custom Assertions
48
52
  def assert_not(expression)
49
- assert_block("Expected <#{expression}> to be false!") { not expression }
53
+ refute expression, "Expected <#{expression}> to be false!"
54
+ end
55
+
56
+ def assert_nothing_raised
57
+ yield
58
+ end
59
+
60
+ def assert_not_includes(array, value)
61
+ refute array.include?(value)
62
+ end
63
+
64
+ def assert_includes(array, value)
65
+ assert array.include?(value)
50
66
  end
51
67
 
52
68
  def load_fixture(name, format=:json)
53
69
  File.read(File.dirname(__FILE__) + "/fixtures/#{name}.#{format}")
54
70
  end
55
71
 
72
+ def assert_request_body(expected)
73
+ assert_equal expected, FakeWeb.last_request.body
74
+ end
75
+
56
76
  def fake(endpoint, options={})
57
77
  body = options.has_key?(:body) ? options.delete(:body) : load_fixture(endpoint)
58
78
  format = options.delete(:format) || :json
metadata CHANGED
@@ -1,36 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZhZG1p
14
- bnMxFzAVBgoJkiaJk/IsZAEZFgdzaG9waWZ5MRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE0MDUxNTIwMzM0OFoXDTE1MDUxNTIwMzM0OFowPzEPMA0GA1UEAwwGYWRt
16
- aW5zMRcwFQYKCZImiZPyLGQBGRYHc2hvcGlmeTETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL0/81O3e1vh5smcwp2G
18
- MpLQ6q0kejQLa65bPYPxdzWA1SYOKyGfw+yR9LdFzsuKpwWzKq6zX35lj1IckWS4
19
- bNBEQzxmufUxU0XPM02haFB8fOfDJzdXsWte9Ge4IFwahwn68gpMqN+BvxL+KMYz
20
- Iut9YmN44d4LZdsENEIO5vmybuG2vYDz7R56qB0PA+Q2P2CdhymsBad2DQs69FBo
21
- uico9V6VMYYctL9lCYdzu9IXrOYNTt88suKIVzzAlHOKeN0Ng5qdztFoTR8sfxDr
22
- Ydg3KHl5n47wlpgd8R0f/4b5gGxW+v9pyJCgQnLlRu7DedVSvv7+GMtj3g9r3nhJ
23
- KqECAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFI/o
24
- maf34HXbUOQsdoLHacEKQgunMB0GA1UdEQQWMBSBEmFkbWluc0BzaG9waWZ5LmNv
25
- bTAdBgNVHRIEFjAUgRJhZG1pbnNAc2hvcGlmeS5jb20wDQYJKoZIhvcNAQEFBQAD
26
- ggEBADkK9aj5T0HPExsov4EoMWFnO+G7RQ28C30VAfKxnL2UxG6i4XMHVs6Xi94h
27
- qXFw1ec9Y2eDUqaolT3bviOk9BB197+A8Vz/k7MC6ci2NE+yDDB7HAC8zU6LAx8Y
28
- Iqvw7B/PSZ/pz4bUVFlTATif4mi1vO3lidRkdHRtM7UePSn2rUpOi0gtXBP3bLu5
29
- YjHJN7wx5cugMEyroKITG5gL0Nxtu21qtOlHX4Hc4KdE2JqzCPOsS4zsZGhgwhPs
30
- fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
31
- TConQSX2BnZdhIEYW+cKzEC/bLc=
32
- -----END CERTIFICATE-----
33
- date: 2015-05-12 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2015-06-02 00:00:00.000000000 Z
34
12
  dependencies:
35
13
  - !ruby/object:Gem::Dependency
36
14
  name: activeresource
@@ -302,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
280
  version: '0'
303
281
  requirements: []
304
282
  rubyforge_project:
305
- rubygems_version: 2.2.2
283
+ rubygems_version: 2.2.3
306
284
  signing_key:
307
285
  specification_version: 4
308
286
  summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web
checksums.yaml.gz.sig DELETED
Binary file
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file