shutl_resource 1.8.2 → 1.9.0

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: 500c2ab1f17cb6cf8130a6add480df375ddb3820
4
- data.tar.gz: 15799d11ac8846e9451b9ac4c1f1c265cf971137
3
+ metadata.gz: 9193516a7835099997481b7a29524fe83868e53f
4
+ data.tar.gz: dd95aa8e494ca22eb997168f9bd4d3498eb959d8
5
5
  SHA512:
6
- metadata.gz: 98e554b684023c9a6ab7f74039d1e1d7152f4839d90272c723b2ca411ddc3f23665e53f0cca6d100d770612c6cef57f63c0e4ea7c0f791f6dc9a88a8f6754ae4
7
- data.tar.gz: c2355f511c325103a30888fb5285af2759c199184686bcba8f873f7c0478eb681c3b3b7b11787072cc1607c257dd8e749d6683b9895493bb12785c42f9c52a05
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
@@ -1,5 +1,5 @@
1
1
  module Shutl
2
2
  module Resource
3
- VERSION = '1.8.2'
3
+ VERSION = '1.9.0'
4
4
  end
5
5
  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.8.2
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-09-15 00:00:00.000000000 Z
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.4.5.1
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