alephant-broker 3.4.0 → 3.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 +4 -4
- data/lib/alephant/broker/component.rb +11 -5
- data/lib/alephant/broker/version.rb +1 -1
- data/spec/integration/rack_spec.rb +35 -15
- data/spec/integration/spec_helper.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66e7169ca6dccf162a18d99cd370e664743f7368
|
4
|
+
data.tar.gz: ed5178f9dc74b2f4b339ceffe9c2a1aff969c566
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d761eaba217f4f256ccd1544063d237624af19f4609d9880cfc09694d15c8767c80b423bc8974e6d235d9603c28e808f79d9f358a61b59bad4ca93e0674f324b
|
7
|
+
data.tar.gz: 12b02ddece7cdd609f018b99a080e735bc57993ec472409bc492f6a68418f0bbd95c8635e37154ec92b87c2d62d56f33c999fcce06045df17b0a32cb6ea7df49
|
@@ -10,6 +10,8 @@ module Alephant
|
|
10
10
|
class Component
|
11
11
|
attr_reader :id, :batch_id, :options, :content, :opts_hash
|
12
12
|
|
13
|
+
HEADER_PREFIX = "head_"
|
14
|
+
|
13
15
|
def initialize(meta, data)
|
14
16
|
@id = meta.id
|
15
17
|
@batch_id = meta.batch_id
|
@@ -29,11 +31,11 @@ module Alephant
|
|
29
31
|
"Content-Type" => data[:content_type].to_s
|
30
32
|
}
|
31
33
|
.merge(data[:headers] || {})
|
32
|
-
.merge(
|
34
|
+
.merge(meta_data_headers)
|
33
35
|
end
|
34
36
|
|
35
37
|
def status
|
36
|
-
|
38
|
+
data[:meta].key?("status") ? data[:meta]["status"] : 200
|
37
39
|
end
|
38
40
|
|
39
41
|
private
|
@@ -41,11 +43,15 @@ module Alephant
|
|
41
43
|
attr_reader :meta, :data
|
42
44
|
|
43
45
|
def meta_data_headers
|
44
|
-
@meta_data_headers ||= data[:meta].
|
46
|
+
@meta_data_headers ||= data[:meta].to_h.reduce({}) do |accum, (k, v)|
|
47
|
+
accum.tap do |a|
|
48
|
+
a[header_key(k)] = v.to_s if k.start_with?(HEADER_PREFIX)
|
49
|
+
end
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
47
|
-
def
|
48
|
-
|
53
|
+
def header_key(key)
|
54
|
+
key.gsub(HEADER_PREFIX, "").split("-").map(&:capitalize).join("-")
|
49
55
|
end
|
50
56
|
|
51
57
|
def symbolize(hash)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "spec_helper"
|
2
2
|
|
3
3
|
describe Alephant::Broker::Application do
|
4
4
|
include Rack::Test::Methods
|
@@ -17,11 +17,11 @@ describe Alephant::Broker::Application do
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
let(:content) do
|
20
|
-
|
20
|
+
AWS::Core::Data.new(
|
21
21
|
:content_type => "test/content",
|
22
22
|
:content => "Test",
|
23
23
|
:meta => {}
|
24
|
-
|
24
|
+
)
|
25
25
|
end
|
26
26
|
let(:sequencer_double) do
|
27
27
|
instance_double(
|
@@ -104,12 +104,10 @@ describe Alephant::Broker::Application do
|
|
104
104
|
|
105
105
|
describe "S3 headers" do
|
106
106
|
let(:content) do
|
107
|
-
|
107
|
+
AWS::Core::Data.new(
|
108
108
|
:content => "missing_content",
|
109
|
-
:meta => {
|
110
|
-
|
111
|
-
}
|
112
|
-
}
|
109
|
+
:meta => {}
|
110
|
+
)
|
113
111
|
end
|
114
112
|
let(:s3_cache_double) do
|
115
113
|
instance_double(
|
@@ -120,7 +118,7 @@ describe Alephant::Broker::Application do
|
|
120
118
|
|
121
119
|
context "with 404 status code set" do
|
122
120
|
before do
|
123
|
-
content[:meta][
|
121
|
+
content[:meta]["status"] = 404
|
124
122
|
allow(Alephant::Cache).to receive(:new) { s3_cache_double }
|
125
123
|
get "/component/test_component"
|
126
124
|
end
|
@@ -130,17 +128,39 @@ describe Alephant::Broker::Application do
|
|
130
128
|
|
131
129
|
context "with cache and additional headers set" do
|
132
130
|
before do
|
133
|
-
content[:meta]
|
134
|
-
"
|
135
|
-
"
|
136
|
-
"
|
131
|
+
content[:meta] = {
|
132
|
+
"head_cache-control" => "max-age=60",
|
133
|
+
"head_x-some-header" => "foo",
|
134
|
+
"head_header_without_dash" => "bar",
|
135
|
+
"status" => 200
|
137
136
|
}
|
138
137
|
allow(Alephant::Cache).to receive(:new) { s3_cache_double }
|
139
138
|
get "/component/test_component"
|
140
139
|
end
|
141
140
|
|
142
|
-
specify
|
143
|
-
|
141
|
+
specify do
|
142
|
+
expect(
|
143
|
+
last_response.headers
|
144
|
+
).to include_case_sensitive("Cache-Control")
|
145
|
+
end
|
146
|
+
specify do
|
147
|
+
expect(
|
148
|
+
last_response.headers["Cache-Control"]
|
149
|
+
).to eq(content[:meta]["head_cache-control"])
|
150
|
+
end
|
151
|
+
|
152
|
+
specify do
|
153
|
+
expect(
|
154
|
+
last_response.headers
|
155
|
+
).to include_case_sensitive("X-Some-Header")
|
156
|
+
end
|
157
|
+
|
158
|
+
specify do
|
159
|
+
expect(
|
160
|
+
last_response.headers
|
161
|
+
).to include_case_sensitive("Header_without_dash")
|
162
|
+
end
|
163
|
+
|
144
164
|
specify { expect(last_response.headers).to_not include("Status") }
|
145
165
|
specify { expect(last_response.status).to eq 200 }
|
146
166
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Jack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|