active_fulfillment 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c44a6365ceec8b87932cd38f60aa054cb454da7
4
- data.tar.gz: 4ae3e1997771d41d0df24e710be64af80e28e01c
3
+ metadata.gz: c116080121697527325b266bda808c6acea1be1e
4
+ data.tar.gz: d49f7f6df9eeaaa9fad7d40a2cd2080f981be35f
5
5
  SHA512:
6
- metadata.gz: db5d2187c183888f1e7aba008977cefcf73a34895cd56f1ab802018916a68abd3b9f548c2d0322fc9027a2e6e24b7a51d930c2a961c836a758b4436ac845eff8
7
- data.tar.gz: d18c9ec1bb040afb698a4e6e243d447b60f4438590664b38774e3810345cab77ab724fdf4c247819e22b7a8c16d3d99b89c63efeb32c7ffa6df69dbe95be69c8
6
+ metadata.gz: 3fbcca254fb6aca6b40371c6ab89a3bc9f07873bcfa61df02c64cc433c3243489f365e6d8a33842576557de1bf8dddfbb573f06268f662751065ff011294801a
7
+ data.tar.gz: 3f71ad76b4776338811db3787c7e14f8864534662eb9bb2452f8d380fa427a8ad44eb2248328653f75a9acbd010c087b49fe97d19d4ac068c19103fb121d64f4
@@ -26,6 +26,7 @@ require 'active_support/core_ext/time/calculations'
26
26
  require 'active_support/core_ext/date/calculations'
27
27
  require 'active_support/core_ext/numeric/time'
28
28
  require 'active_support/core_ext/enumerable'
29
+ require 'active_support/core_ext/string'
29
30
  begin
30
31
  require 'active_support/core_ext/time/acts_like'
31
32
  rescue LoadError
@@ -6,6 +6,8 @@ module ActiveFulfillment
6
6
 
7
7
  OrderIdCutoffDate = Date.iso8601('2015-03-01').freeze
8
8
 
9
+ MAX_LOGGED_RESPONSE_LENGTH = 70
10
+
9
11
  RESCUABLE_CONNECTION_ERRORS = [
10
12
  Net::ReadTimeout,
11
13
  Net::OpenTimeout,
@@ -86,11 +88,20 @@ module ActiveFulfillment
86
88
  end
87
89
  end
88
90
 
89
- log :info, "GET response action=#{action} in #{"%.4fs" % realtime} #{response}"
90
-
91
+ log_response(action, realtime, response)
91
92
  response
92
93
  end
93
94
 
95
+ def log_response(action, realtime, response)
96
+ truncated = response.to_s.truncate(
97
+ MAX_LOGGED_RESPONSE_LENGTH,
98
+ omission: '[response truncated]'
99
+ )
100
+
101
+ log :info, "GET response action=#{action} in " \
102
+ "#{format('%.4fs', realtime)} #{truncated}"
103
+ end
104
+
94
105
  def parse_json(json_data, root)
95
106
  response_data = ActiveSupport::JSON.decode(json_data)
96
107
  return {} unless response_data.is_a?(Hash)
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module ActiveFulfillment
3
- VERSION = "3.2.3"
3
+ VERSION = "3.2.4"
4
4
  end
@@ -107,8 +107,46 @@ class ShopifyAPITest < Minitest::Test
107
107
  refute @service.fetch_stock_levels.success?
108
108
  end
109
109
 
110
+ def test_fetch_tracking_data_logs_the_response
111
+ response = 'some response'
112
+ @service.expects(:ssl_get).returns(response)
113
+
114
+ expected = ".* GET response action=fetch_tracking_numbers in .* #{response}"
115
+
116
+ assert_log(:info, expected) do
117
+ @service.fetch_tracking_data([1, 2])
118
+ end
119
+ end
120
+
121
+ def test_fetch_tracking_data_logs_the_truncated_response
122
+ response = 'some response. ' * 144
123
+ @service.expects(:ssl_get).returns(response)
124
+
125
+ expected = '.* GET response action=fetch_tracking_numbers in .* ' \
126
+ 'some response. some response. some response. some ' \
127
+ '\[response truncated\]'
128
+
129
+ assert_log(:info, expected) do
130
+ @service.fetch_tracking_data([1, 2])
131
+ end
132
+ end
133
+
110
134
  private
111
135
 
136
+ def assert_log(level, expected)
137
+ r = Regexp.new(expected)
138
+
139
+ matches = false
140
+ @service.class.logger.expects(level).with do |message|
141
+ matches ||= r.match(message).present?
142
+ true
143
+ end.at_least_once
144
+
145
+ yield
146
+ ensure
147
+ assert matches, "Log didn't match #{r}"
148
+ end
149
+
112
150
  def mock_app_request(action, input, output)
113
151
  ActiveFulfillment::ShopifyAPIService.any_instance.expects(:send_app_request).with(action, nil, input).returns(output)
114
152
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fulfillment
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Fauser
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-05 00:00:00.000000000 Z
12
+ date: 2018-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,7 +17,7 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.2.9
20
+ version: 4.2.0
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
23
  version: '6.0'
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: 3.2.9
30
+ version: 4.2.0
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '6.0'
@@ -183,9 +183,9 @@ require_paths:
183
183
  - lib
184
184
  required_ruby_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - ">="
186
+ - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: '0'
188
+ version: '2.2'
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - ">="