alephant-broker 1.1.0 → 1.1.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 +10 -4
- data/lib/alephant/broker/version.rb +1 -1
- data/spec/rack_spec.rb +49 -25
- 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: 6d7dbbfe2023708095fe2f28cd6c85e55c1b8d73
|
4
|
+
data.tar.gz: ffc1205fcacde38bc5c28210f798eb2d17c5c41d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8295834e37a3a4bc6be091b99d5de8f3bdb6fc60b3b5cff9af8857cfb7611e229c863d62397e9899d5a6689514981058bfe0e8ea515554a4ea2a67a3270b046
|
7
|
+
data.tar.gz: 27142031810701e294e98805c79a592ae2e2343767434382b2e15ba5abb24cfb43ef2962b608359289f635a166c98c8b476fd1846a40718caaaa5f6f72216d88
|
@@ -23,8 +23,12 @@ module Alephant
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def load
|
26
|
+
# binding.pry
|
26
27
|
@content_type = cache_object[:content_type]
|
27
28
|
@content = cache_object[:content]
|
29
|
+
rescue
|
30
|
+
@content_type = 'text/html'
|
31
|
+
@content = @cache.set(cache_key, retrieve_object)
|
28
32
|
end
|
29
33
|
|
30
34
|
def opts_hash
|
@@ -38,10 +42,12 @@ module Alephant
|
|
38
42
|
private
|
39
43
|
|
40
44
|
def cache_object
|
41
|
-
@cache_object ||= @cache.get(cache_key)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
@cache_object ||= @cache.get(cache_key) { retrieve_object }
|
46
|
+
end
|
47
|
+
|
48
|
+
def retrieve_object
|
49
|
+
@cached = false
|
50
|
+
s3.get(s3_path)
|
45
51
|
end
|
46
52
|
|
47
53
|
def cache_key
|
data/spec/rack_spec.rb
CHANGED
@@ -10,29 +10,29 @@ end
|
|
10
10
|
|
11
11
|
describe 'Broker Rack Application' do
|
12
12
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Alephant::Broker::
|
19
|
-
.
|
20
|
-
.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
.
|
25
|
-
|
13
|
+
cache_hash = {
|
14
|
+
:content_type => 'test/content',
|
15
|
+
:content => 'Test'
|
16
|
+
}
|
17
|
+
|
18
|
+
allow_any_instance_of(Alephant::Broker::Cache::Client)
|
19
|
+
.to receive(:get)
|
20
|
+
.and_return(cache_hash)
|
21
|
+
|
22
|
+
allow_any_instance_of(Alephant::Broker::Component)
|
23
|
+
.to receive(:content)
|
24
|
+
.and_return(cache_hash[:content])
|
25
|
+
|
26
|
+
allow_any_instance_of(Alephant::Broker::Component)
|
27
|
+
.to receive(:content_type)
|
26
28
|
.and_return('foo/bar')
|
27
29
|
|
28
|
-
Alephant::Broker::Component
|
29
|
-
.
|
30
|
-
.stub(:version)
|
30
|
+
allow_any_instance_of(Alephant::Broker::Component)
|
31
|
+
.to receive(:version)
|
31
32
|
.and_return(1)
|
32
33
|
|
33
|
-
Alephant::Broker::Response::Asset
|
34
|
-
.
|
35
|
-
.stub(:status)
|
34
|
+
allow_any_instance_of(Alephant::Broker::Response::Asset)
|
35
|
+
.to receive(:status)
|
36
36
|
.and_return(200)
|
37
37
|
end
|
38
38
|
|
@@ -71,9 +71,8 @@ describe 'Broker Rack Application' do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "Tests 404 when lookup doesn't return a valid location" do
|
74
|
-
Alephant::Broker::Response::Asset
|
75
|
-
.
|
76
|
-
.stub(:status)
|
74
|
+
allow_any_instance_of(Alephant::Broker::Response::Asset)
|
75
|
+
.to receive(:status)
|
77
76
|
.and_return(404)
|
78
77
|
|
79
78
|
get '/component/test_component'
|
@@ -82,9 +81,8 @@ describe 'Broker Rack Application' do
|
|
82
81
|
end
|
83
82
|
|
84
83
|
it "Tests 500 when exception is raised in application" do
|
85
|
-
Alephant::Broker::Response::Asset
|
86
|
-
.
|
87
|
-
.stub(:status)
|
84
|
+
allow_any_instance_of(Alephant::Broker::Response::Asset)
|
85
|
+
.to receive(:status)
|
88
86
|
.and_return(500)
|
89
87
|
|
90
88
|
get '/component/test_component'
|
@@ -101,4 +99,30 @@ describe 'Broker Rack Application' do
|
|
101
99
|
expect(last_response).to be_ok
|
102
100
|
expect(last_response.body).to eq(compiled_json)
|
103
101
|
end
|
102
|
+
|
103
|
+
it "Should handle old cache data gracefully" do
|
104
|
+
lookup_location_double = double('Alephant::Lookup::Location', :location => 'test/location')
|
105
|
+
lookup_helper_double = double('Alephant::Lookup::LookupHelper', :read => lookup_location_double)
|
106
|
+
|
107
|
+
cache_double = double('Alephant::Broker::Cache::Client', :set => nil, :get => '<p>Some data</p>')
|
108
|
+
s3_cache_double = double('Alephant::Cache', :get => 'test_content')
|
109
|
+
|
110
|
+
allow(Alephant::Lookup)
|
111
|
+
.to receive(:create)
|
112
|
+
.and_return(lookup_helper_double)
|
113
|
+
|
114
|
+
allow(Alephant::Broker::Cache::Client)
|
115
|
+
.to receive(:new)
|
116
|
+
.and_return(cache_double)
|
117
|
+
|
118
|
+
allow(Alephant::Cache)
|
119
|
+
.to receive(:new)
|
120
|
+
.and_return(s3_cache_double)
|
121
|
+
|
122
|
+
expect(cache_double).to receive(:set).once
|
123
|
+
|
124
|
+
get '/component/test_component'
|
125
|
+
|
126
|
+
end
|
127
|
+
|
104
128
|
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: 1.1.
|
4
|
+
version: 1.1.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: 2014-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|