active_rest_client 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_rest_client/caching.rb +2 -2
- data/lib/active_rest_client/version.rb +1 -1
- data/spec/lib/caching_spec.rb +8 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77e442c1fd4bf22c3ef98a18bb9f67d034d13dcb
|
4
|
+
data.tar.gz: eb7c6b99213a31eb56f69c276642fe03825e3a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f21a5d8fad3841c0891d4a619d59b6bdaf0f5f920c4512cf3be1b9eb72b9d8f7d2ac1acff05ce62a3aef9cbb17661c5f1ebedd13943863c149b4b63ad3ba7e47
|
7
|
+
data.tar.gz: 7ed888f35736130ffc40118dbde8ec51f764d13f38cb48fcc5b71337b4fbd2a45a0cd77aee19ea96d6135f3c66393272406391a7924cc7338771a2562e3eef73
|
@@ -66,8 +66,8 @@ module ActiveRestClient
|
|
66
66
|
ActiveRestClient::Logger.debug " \033[1;4;32m#{ActiveRestClient::NAME}\033[0m #{key} - Writing to cache"
|
67
67
|
cached_response = CachedResponse.new(status:response.status, result:result)
|
68
68
|
cached_response.etag = response.headers[:etag] if response.headers[:etag]
|
69
|
-
cached_response.expires = Time.parse(response.headers[:expires]) if response.headers[:expires]
|
70
|
-
cache_store.write(key, Marshal.dump(cached_response), {})
|
69
|
+
cached_response.expires = Time.parse(response.headers[:expires]) rescue nil if response.headers[:expires]
|
70
|
+
cache_store.write(key, Marshal.dump(cached_response), {}) if cached_response.etag.present? || cached_response.expires
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/spec/lib/caching_spec.rb
CHANGED
@@ -198,6 +198,14 @@ describe ActiveRestClient::Caching do
|
|
198
198
|
ret = Person.all
|
199
199
|
end
|
200
200
|
|
201
|
+
it "should not write the response to the cache if there's an invalid expiry" do
|
202
|
+
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
203
|
+
expect_any_instance_of(CachingExampleCacheStore5).to_not receive(:write).once.with("Person:/", an_instance_of(String), an_instance_of(Hash))
|
204
|
+
expect_any_instance_of(ActiveRestClient::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(OpenStruct.new(status:200, body:"{\"result\":true}", headers:{expires:"0"}))
|
205
|
+
Person.perform_caching = true
|
206
|
+
ret = Person.all
|
207
|
+
end
|
208
|
+
|
201
209
|
end
|
202
210
|
|
203
211
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_rest_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Which Ltd
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -299,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
299
|
version: '0'
|
300
300
|
requirements: []
|
301
301
|
rubyforge_project:
|
302
|
-
rubygems_version: 2.4.
|
302
|
+
rubygems_version: 2.4.6
|
303
303
|
signing_key:
|
304
304
|
specification_version: 4
|
305
305
|
summary: This gem is for accessing REST services in an ActiveRecord style. ActiveResource
|
@@ -325,3 +325,4 @@ test_files:
|
|
325
325
|
- spec/lib/result_iterator_spec.rb
|
326
326
|
- spec/lib/validation_spec.rb
|
327
327
|
- spec/spec_helper.rb
|
328
|
+
has_rdoc:
|