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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cebf819da714467f9faec319d6343c6e0d086117
4
- data.tar.gz: d154fe7544fb5f9f904a5f5849817547bb897629
3
+ metadata.gz: 6d7dbbfe2023708095fe2f28cd6c85e55c1b8d73
4
+ data.tar.gz: ffc1205fcacde38bc5c28210f798eb2d17c5c41d
5
5
  SHA512:
6
- metadata.gz: 5730739e5d7abc50fcbc385a6e06521b93a4ddd14c396abcf177bfd3a3db8da2ca0befb8fd4b18193582d54b31504d2e60253769746661dbde88d13beb83b2d6
7
- data.tar.gz: 19029f98faa67945a4947cb40d31a5b296de6d52a228a2817b2f5bd264a481d9b66761c96c3243a7546b55fd25e8086911625653da7c7a34d62dd5a3d4684e92
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) do
42
- @cached = false
43
- s3.get(s3_path)
44
- end
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
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -10,29 +10,29 @@ end
10
10
 
11
11
  describe 'Broker Rack Application' do
12
12
  before do
13
- Alephant::Broker::Component
14
- .any_instance
15
- .stub(:load)
16
- .and_return('Test')
17
-
18
- Alephant::Broker::Component
19
- .any_instance
20
- .stub(:content)
21
- .and_return('Test')
22
-
23
- Alephant::Broker::Component
24
- .any_instance
25
- .stub(:content_type)
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
- .any_instance
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
- .any_instance
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
- .any_instance
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
- .any_instance
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.0
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-07-09 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec