active_rest_client 1.0.8 → 1.0.9

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: 323d3696fb921ff5d23de556ec82ca0ee07fadea
4
- data.tar.gz: 852a377147513500e2a0d1fdc92bbdf38d30c76d
3
+ metadata.gz: 77e442c1fd4bf22c3ef98a18bb9f67d034d13dcb
4
+ data.tar.gz: eb7c6b99213a31eb56f69c276642fe03825e3a9d
5
5
  SHA512:
6
- metadata.gz: 911ece68f67242d67f06e279f13398624ed35a0828dd92e2f960b8ceb9ed1663b6790f8f25899e2b9224ff7fb2182fe7faf4d68eb4b64cc7451a1075de655afb
7
- data.tar.gz: f62c9f442fe875811da762bcb6b87a3a7d52ccd3cd161b8926a1397b201f0fdf0112eade77ae1b6bcd8d8fca8bb5b570b05fc5e2554a87dc155798ffc4ea0398
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
@@ -1,3 +1,3 @@
1
1
  module ActiveRestClient
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
@@ -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.8
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-04-01 00:00:00.000000000 Z
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.5
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: