hoodoo 2.4.0 → 2.4.1

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
  SHA256:
3
- metadata.gz: 28c5549a689e0e841a9c435f0c6a5bfe502f4b592b4bdcec929d0680818e5d3c
4
- data.tar.gz: c41b08c154c94b959c674b4c5acf3da3e9174b83fd3ab7b210adcc51aeaa8991
3
+ metadata.gz: 15b068238ef0e8f90fc5cedd67ce619250ff4ee1babf3025ce2f64808d2cab5f
4
+ data.tar.gz: 5528ad58d765ad928bf41879199f2c17a2786f63aa7646152da797cd5aa4f5c4
5
5
  SHA512:
6
- metadata.gz: 271dbaf036afd87732ff3f702fc82b0a1e8abc334531f9b62f2bac266f9b258b65e8fe42c8bc865a70f39e6624e7e15611ed17ca158cc8b59ecd4ef501a8a77a
7
- data.tar.gz: f3355e88dabae561eaf7ef72adccb57606f33df0f2593e0ef0963aa7c85c3526831bdc95012bf6a4f0954bd1e9d5fed9f89d0c6aaca69447afffc75df1d1f237
6
+ metadata.gz: 7d6a965fdeae003aeede10bd9a0153bf663186e5fa0b7318d5abe9fc288f647e334e44bb00d6092f2ff52062fd460c422f715519a600b09ebb0b2743ec8c21a9
7
+ data.tar.gz: 9295602ffeb5a2b40cf660aa7ddb913bcc35b5f4e4cd4e3ceadcd834dc6288ee1faa6cf3c13a072309078517cf6b723a955215f56080ef1f31ac0ae818ffda9e
@@ -342,7 +342,6 @@ module Hoodoo
342
342
 
343
343
  end
344
344
 
345
-
346
345
  public
347
346
 
348
347
  # Obtain a list of resource instance representations.
@@ -358,7 +358,7 @@ module Hoodoo
358
358
  parsed.dataset_size = size
359
359
  parsed.estimated_dataset_size = estimated_size
360
360
 
361
- elsif ( parsed[ 'kind' ] == 'Errors' )
361
+ elsif ( ( code < 200 || code > 299 ) && parsed[ 'kind' ] == 'Errors' )
362
362
 
363
363
  # This isn't an array, it's an AugmentedHash describing errors.
364
364
  # Turn this into a formal errors collection.
@@ -12,11 +12,11 @@ module Hoodoo
12
12
  # The Hoodoo gem version. If this changes, be sure to re-run
13
13
  # <tt>bundle install</tt> or <tt>bundle update</tt>.
14
14
  #
15
- VERSION = '2.4.0'
15
+ VERSION = '2.4.1'
16
16
 
17
17
  # The Hoodoo gem date. If this changes, be sure to re-run
18
18
  # <tt>bundle install</tt> or <tt>bundle update</tt>.
19
19
  #
20
- DATE = '2018-03-21'
20
+ DATE = '2018-04-13'
21
21
 
22
22
  end
@@ -66,6 +66,27 @@ class RSpecClientTestTargetImplementation < Hoodoo::Services::Implementation
66
66
  return
67
67
  end
68
68
 
69
+ # Deliberate 'return an error-like object but with a 200 response
70
+ # code' hook, as if implementing the Errors resource endpoint and
71
+ # successfully processing a request.
72
+ #
73
+ if context.request.ident == 'return_200_with_errors_body'
74
+ context.response.set_resource( {
75
+ 'id' => Hoodoo::UUID.generate(),
76
+ 'kind' => 'Errors',
77
+ 'created_at' => Hoodoo::Utilities.standard_datetime( Time.now ),
78
+ 'errors' => [
79
+ {
80
+ 'code' => 'generic.not_found',
81
+ 'message' => 'Resource not found',
82
+ 'reference' => '1234'
83
+ }
84
+ ]
85
+ } )
86
+
87
+ return
88
+ end
89
+
69
90
  context.response.set_resource( mock( context ) )
70
91
  end
71
92
 
@@ -344,6 +365,20 @@ describe Hoodoo::Client do
344
365
  expect( result.platform_errors.has_errors? ).to eq( true )
345
366
  expect( result.platform_errors.errors[ 0 ][ 'code' ] ).to eq( 'platform.invalid_session' )
346
367
  end
368
+
369
+ # An endpoint returns an Errors resource *because it's meant to*, e.g.
370
+ # it's implementing the Errors resource and successfully processed a
371
+ # request; once upon a time, Hoodoo::Client misinterpreted the JSON
372
+ # response and treated it as an error condition. This test ensures
373
+ # that HTTP response codes are properly considered in conjunction, so
374
+ # that Errors payloads under 2xx response codes are non-error states.
375
+ #
376
+ it '(interprets errors properly)' do
377
+ result = @endpoint.show( 'return_200_with_errors_body' )
378
+
379
+ expect( result.platform_errors.has_errors? ).to eq( false )
380
+ expect( result[ 'kind' ] ).to eq( 'Errors' )
381
+ end
347
382
  end
348
383
 
349
384
  before :each do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoodoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loyalty New Zealand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-21 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dalli