reviewed 0.6.2 → 0.6.3

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: 571f18f181a7c3d85e77d20ee542088bcb4368bf
4
- data.tar.gz: 019fc1a4e87ba8d0d39ccec6386faaf33f89b0b0
3
+ metadata.gz: fa11a3952897f5b9ce559f830e1bfecc7e36f50d
4
+ data.tar.gz: 3eb8766f1d332ea87cf3d51432e1e990a96f0d39
5
5
  SHA512:
6
- metadata.gz: 3f4c6b6b515a849e3b33abc084d1ea9bf1aaef6c93f570b72eba38e677ced21ce67f25ff9d0817991d43984b3c1d8d620245149241a73a61a65725895996535e
7
- data.tar.gz: 068bea025cada9fcee782507522105b5e36352d9915989517448e217e4d8d6ce6d8fe7648bf42192de8e22c35b887e5546c5c5dc66d6e3d56e68c869e5defd2c
6
+ metadata.gz: fa76c100e1ff5f150e03cc8a966828e7f5c13a3b675fed43aa2c71d65ef27d9baaea162c743c93b6a8186e02d889f23f7f838e193f643ecacd83bacdf9cc015b
7
+ data.tar.gz: 73ebf5077ebc656a42df42aaea07206473ce9560662514edd99dfcac291374c7e1aa9e96aa907fe7fca3b3f923b8fc0ac369a59f1368884c1f3780ab441ade9e
@@ -16,11 +16,11 @@ module Faraday
16
16
 
17
17
  @website_id = env[:request_headers]['x-reviewed-website']
18
18
 
19
- if serve_from_cache && store.exist?(cache_key)
19
+ if serve_from_cache? && store.exist?(cache_key)
20
20
  Hashie::Mash.new(Marshal.load( store.read(cache_key) ))
21
21
  else
22
22
  @app.call(env).on_complete do |response|
23
- if store_response
23
+ if store_response?(response)
24
24
  store.delete(cache_key)
25
25
  store.write(cache_key, Marshal.dump(response), write_options)
26
26
  end
@@ -30,11 +30,12 @@ module Faraday
30
30
 
31
31
  private
32
32
 
33
- def serve_from_cache
33
+ def serve_from_cache?
34
34
  @url.query.blank? || !@url.query.match(/\b(skip|reset)-cache\b/)
35
35
  end
36
36
 
37
- def store_response
37
+ def store_response?(resp)
38
+ return false if resp[:status] != 200
38
39
  @url.query.blank? || !@url.query.match(/\bskip-cache\b/)
39
40
  end
40
41
 
@@ -1,4 +1,4 @@
1
1
  module Reviewed
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  API_VERSION = 'v1'
4
4
  end
@@ -10,6 +10,7 @@ describe Faraday::Cache do
10
10
  builder.adapter :test, Faraday::Adapter::Test::Stubs.new do |stub|
11
11
  stub.get('/articles') { [200, {}, 'I like turtles'] }
12
12
  stub.get('/products') { [200, {}, 'Weee products'] }
13
+ stub.get('/kaboom') { [500, {}, 'Kaboom'] }
13
14
  end
14
15
  end
15
16
 
@@ -40,6 +41,11 @@ describe Faraday::Cache do
40
41
  resp[:body].should eq("old musty response")
41
42
  end
42
43
 
44
+ it "does not store response when result is 500" do
45
+ Reviewed::Cache.store.should_not_receive(:write)
46
+ conn.get('/kaboom')
47
+ end
48
+
43
49
  describe "cache busting and skipping" do
44
50
  it "does not cache responses with skip-cache as a query param" do
45
51
  Reviewed::Cache.store.should_not_receive(:read)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reviewed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Plante
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2013-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  version: '0'
313
313
  requirements: []
314
314
  rubyforge_project:
315
- rubygems_version: 2.0.3
315
+ rubygems_version: 2.0.6
316
316
  signing_key:
317
317
  specification_version: 4
318
318
  summary: A Ruby Gem for Accessing the Reviewed.com API