flexirest 1.3.28 → 1.3.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/flexirest/caching.rb +7 -4
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/caching_spec.rb +24 -1
- 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: 09154cafbcffc062d4414e0cb632075b5404fde8
|
4
|
+
data.tar.gz: e5480c5145b3218380e06fd01c67d02956defd2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890f5a711e634ec310a781ccd1e404e53ad7ffa1fc341b077de6277746f5f351c3d833f28883e5c3fef043f2b4351c1d5471f98d7e4610e8aba8ff357c306d65
|
7
|
+
data.tar.gz: 845cad98cb6c3178b14ef44438247c3bf242a70df68ecba002eef1579959b041743171226e6c86fd80633aa2c27bed7a5ec4acfcdf127d83e17076dd64d7ac97
|
data/CHANGELOG.md
CHANGED
data/lib/flexirest/caching.rb
CHANGED
@@ -5,13 +5,16 @@ module Flexirest
|
|
5
5
|
|
6
6
|
def perform_caching(value = nil)
|
7
7
|
@perform_caching ||= nil
|
8
|
-
@@perform_caching ||= nil
|
9
8
|
if value.nil?
|
10
|
-
if @perform_caching.nil?
|
9
|
+
value = if @perform_caching.nil?
|
11
10
|
@@perform_caching
|
12
11
|
else
|
13
12
|
@perform_caching
|
14
13
|
end
|
14
|
+
if value.nil? && superclass.respond_to?(:perform_caching)
|
15
|
+
value = superclass.perform_caching
|
16
|
+
end
|
17
|
+
value
|
15
18
|
else
|
16
19
|
@perform_caching = value
|
17
20
|
end
|
@@ -40,8 +43,8 @@ module Flexirest
|
|
40
43
|
end
|
41
44
|
|
42
45
|
def _reset_caching!
|
43
|
-
@@perform_caching =
|
44
|
-
@perform_caching =
|
46
|
+
@@perform_caching = nil
|
47
|
+
@perform_caching = nil
|
45
48
|
@@cache_store = nil
|
46
49
|
end
|
47
50
|
|
data/lib/flexirest/version.rb
CHANGED
data/spec/lib/caching_spec.rb
CHANGED
@@ -189,7 +189,7 @@ describe Flexirest::Caching do
|
|
189
189
|
expect(ret._status).to eq(200)
|
190
190
|
end
|
191
191
|
|
192
|
-
it "should not write the response to the cache unless
|
192
|
+
it "should not write the response to the cache unless it has caching headers" do
|
193
193
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
194
194
|
expect_any_instance_of(CachingExampleCacheStore5).not_to receive(:write)
|
195
195
|
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(OpenStruct.new(status:200, body:"{\"result\":true}", headers:{}))
|
@@ -204,6 +204,29 @@ describe Flexirest::Caching do
|
|
204
204
|
Person.all
|
205
205
|
end
|
206
206
|
|
207
|
+
it "should not write the response to the cache if there's an etag but perform_caching is off" do
|
208
|
+
expect(Person.cache_store).to_not receive(:read)
|
209
|
+
expect(Person.cache_store).to_not receive(:write)
|
210
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"{\"result\":true}", response_headers:{etag:"1234567890"})))
|
211
|
+
Person.perform_caching false
|
212
|
+
Person.all
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should not write the response to the cache if there's an etag but perform_caching is off at the base level" do
|
216
|
+
begin
|
217
|
+
caching = Flexirest::Base.perform_caching
|
218
|
+
Flexirest::Base.perform_caching false
|
219
|
+
Person._reset_caching!
|
220
|
+
Person.cache_store = CachingExampleCacheStore5.new
|
221
|
+
expect(Person.cache_store).to_not receive(:read)
|
222
|
+
expect(Person.cache_store).to_not receive(:write)
|
223
|
+
expect_any_instance_of(Flexirest::Connection).to receive(:get).with("/", an_instance_of(Hash)).and_return(::FaradayResponseMock.new(OpenStruct.new(status:200, body:"{\"result\":true}", response_headers:{etag:"1234567890"})))
|
224
|
+
Person.all
|
225
|
+
ensure
|
226
|
+
Flexirest::Base.perform_caching caching
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
207
230
|
it "should write the response to the cache if there's a hard expiry" do
|
208
231
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:read).once.with("Person:/").and_return(nil)
|
209
232
|
expect_any_instance_of(CachingExampleCacheStore5).to receive(:write).once.with("Person:/", an_instance_of(String), an_instance_of(Hash))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexirest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|