shutl_resource 1.8.2 → 1.9.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.
- checksums.yaml +4 -4
- data/lib/shutl/resource/rest_class_methods.rb +5 -0
- data/lib/shutl/resource/version.rb +1 -1
- data/spec/request_headers_spec.rb +24 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9193516a7835099997481b7a29524fe83868e53f
|
4
|
+
data.tar.gz: dd95aa8e494ca22eb997168f9bd4d3498eb959d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34c79b4ce9ebacbd56b5e8153b92f7abd5e2f609e2f31a2d40e20c0a7db18054a65edf569bcda4be1e54bf67ec2ca37e8203da55270ec35678113a4b5115a10
|
7
|
+
data.tar.gz: ea595f4d869c8f4304f230adffdd4bbc02c9c57ea97233ba3fa4d4928155302a3ebd86f655e1802917a11b575ed8e0e7618354cc86ea95955caa13b451c6f2c6
|
@@ -254,9 +254,14 @@ module Shutl::Resource
|
|
254
254
|
header_opts = params[:headers] || {}
|
255
255
|
header_opts.merge!(authorization: "Bearer #{params[:auth]}") if params[:auth]
|
256
256
|
header_opts.merge!(from: current_user_email(params)) if current_user_email(params)
|
257
|
+
header_opts.merge!(HTTP_X_REQUEST_ID: request_id) if request_id
|
257
258
|
header_opts
|
258
259
|
end
|
259
260
|
|
261
|
+
def request_id
|
262
|
+
Thread.current[:request_group_id]
|
263
|
+
end
|
264
|
+
|
260
265
|
def current_user_email params
|
261
266
|
params[:from] || Thread.current[:user_email]
|
262
267
|
end
|
@@ -10,7 +10,8 @@ describe Shutl::Resource::Rest do
|
|
10
10
|
'Authorization' => 'some auth',
|
11
11
|
'Content-Type' => 'application/json+consumer',
|
12
12
|
'User-Agent' => "Shutl Resource Gem v#{Shutl::Resource::VERSION}",
|
13
|
-
'Consumer-Access-Token' => 'ConsumerAccessToken'
|
13
|
+
'Consumer-Access-Token' => 'ConsumerAccessToken',
|
14
|
+
'Http-X-Request-Id' => 'ABCDE123'
|
14
15
|
}
|
15
16
|
}
|
16
17
|
end
|
@@ -31,6 +32,10 @@ describe Shutl::Resource::Rest do
|
|
31
32
|
}
|
32
33
|
}
|
33
34
|
|
35
|
+
before do
|
36
|
+
Thread.stub(:current).and_return({:request_group_id => "ABCDE123"})
|
37
|
+
end
|
38
|
+
|
34
39
|
describe 'prepends Bearer if auth is passed in for authorization' do
|
35
40
|
let(:resource) { TestSingularResource.new }
|
36
41
|
let(:expected_headers) {
|
@@ -40,6 +45,7 @@ describe Shutl::Resource::Rest do
|
|
40
45
|
'Authorization' => 'Bearer some_auth',
|
41
46
|
'Content-Type' => 'application/json',
|
42
47
|
'User-Agent' => "Shutl Resource Gem v#{Shutl::Resource::VERSION}",
|
48
|
+
'X-Request_Id' => 'ABCDE123'
|
43
49
|
}
|
44
50
|
}
|
45
51
|
before do
|
@@ -56,6 +62,23 @@ describe Shutl::Resource::Rest do
|
|
56
62
|
|
57
63
|
end
|
58
64
|
|
65
|
+
context 'no request id is stored in Thread' do
|
66
|
+
let(:resource) { TestSingularResource.new }
|
67
|
+
|
68
|
+
before do
|
69
|
+
Thread.stub(:current).and_return({})
|
70
|
+
@request = stub_request(:get, 'http://host/test_singular_resource')
|
71
|
+
.with(expected_headers[:headers].except("X-Request-Id"))
|
72
|
+
.to_return(:status => 200,
|
73
|
+
:body => '{"test_singular_resource": { "a": "a", "b": 2 }}',
|
74
|
+
:headers => response_headers)
|
75
|
+
end
|
76
|
+
it 'queries the endpoint' do
|
77
|
+
TestSingularResource.find()
|
78
|
+
@request.should have_been_requested
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
59
82
|
|
60
83
|
describe '#find' do
|
61
84
|
context "with a singular resource" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shutl_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Rouchy
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-
|
16
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: shutl_auth
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
194
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
195
|
+
rubygems_version: 2.2.2
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Manage Shutl Rest resource. Parse/Serialize JSON
|