alephant-broker 3.15.2 → 3.16.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 439cfba9dae34a1931b2bb86e829c3f6da30f268
|
4
|
+
data.tar.gz: a025262a57c2ad7d236456002f629aa0d64e0533
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d0de2d1a911fda4e049e8f4a160ae3be58707b5edc9d9aecda62ccd4bd020287528b0065b2990e899cf6ee88467f88688f4a03567b577a40af3cc3b77fc615c
|
7
|
+
data.tar.gz: 9a0b598a6a517e7f2f4dc9146c7b197de5daa8d8c55238c54ffdaf650adf293152592bfe963d83a74d4857d1ff8591ef91339979d04e5d782884cdb304ca0030
|
@@ -21,6 +21,8 @@ module Alephant
|
|
21
21
|
|
22
22
|
data = loaded_content.to_h
|
23
23
|
data.fetch(:meta, {})[:status] = 200
|
24
|
+
add_revalidating_headers(data) if loaded_content.expired?
|
25
|
+
|
24
26
|
data
|
25
27
|
rescue *STORAGE_ERRORS
|
26
28
|
update_content(component_meta)
|
@@ -59,6 +61,11 @@ module Alephant
|
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
64
|
+
def add_revalidating_headers(data)
|
65
|
+
data[:headers] ||= {}
|
66
|
+
data[:headers]['broker-cache'] = 'revalidating'
|
67
|
+
end
|
68
|
+
|
62
69
|
def fetch_stored_content(component_meta)
|
63
70
|
Fetcher.new(component_meta).fetch
|
64
71
|
rescue *STORAGE_ERRORS
|
@@ -28,6 +28,14 @@ RSpec.describe Alephant::Broker::LoadStrategy::Revalidate::Strategy do
|
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
|
+
let(:expected_revalidating_content) do
|
32
|
+
revalidating_content = expected_content.clone
|
33
|
+
revalidating_content[:headers] = {
|
34
|
+
'broker-cache' => 'revalidating'
|
35
|
+
}
|
36
|
+
revalidating_content
|
37
|
+
end
|
38
|
+
|
31
39
|
let(:cached_obj) do
|
32
40
|
Alephant::Broker::Cache::CachedObject.new(content)
|
33
41
|
end
|
@@ -66,6 +74,13 @@ RSpec.describe Alephant::Broker::LoadStrategy::Revalidate::Strategy do
|
|
66
74
|
|
67
75
|
subject.load(component_meta)
|
68
76
|
end
|
77
|
+
|
78
|
+
it 'does NOT send the revalidating repsonse header' do
|
79
|
+
response = subject.load(component_meta)
|
80
|
+
response_headers = response[:headers] || {}
|
81
|
+
|
82
|
+
expect(response_headers['broker-cache']).to_not eq('revalidating')
|
83
|
+
end
|
69
84
|
end
|
70
85
|
|
71
86
|
context 'which has expired' do
|
@@ -88,7 +103,11 @@ RSpec.describe Alephant::Broker::LoadStrategy::Revalidate::Strategy do
|
|
88
103
|
end
|
89
104
|
|
90
105
|
it 'it gets fetched from the cache and returned to the user' do
|
91
|
-
expect(subject.load(component_meta)).to eq(
|
106
|
+
expect(subject.load(component_meta)).to eq(expected_revalidating_content)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should contain a revalidating reponse header' do
|
110
|
+
expect(subject.load(component_meta)[:headers]['broker-cache']).to eq('revalidating')
|
92
111
|
end
|
93
112
|
|
94
113
|
context 'in the background...' do
|
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
|
+
version: 3.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BBC News
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|