zendesk_api 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -30,7 +30,12 @@ module ZendeskAPI
|
|
30
30
|
|
31
31
|
@app.call(env).on_complete do
|
32
32
|
if cached && env[:status] == 304 # not modified
|
33
|
-
env
|
33
|
+
env[:body] = cached[:body]
|
34
|
+
env[:response_headers].merge!(
|
35
|
+
:etag => cached[:response_headers][:etag],
|
36
|
+
:content_type => cached[:response_headers][:content_type],
|
37
|
+
:content_length => cached[:response_headers][:content_length]
|
38
|
+
)
|
34
39
|
elsif env[:status] == 200 && env[:response_headers]["Etag"] # modified and cacheable
|
35
40
|
@cache.write(cache_key(env), env)
|
36
41
|
end
|
data/lib/zendesk_api/version.rb
CHANGED
@@ -5,16 +5,17 @@ describe ZendeskAPI::Middleware::Request::EtagCache do
|
|
5
5
|
client.config.cache.size = 1
|
6
6
|
|
7
7
|
stub_json_request(:get, %r{blergh}, '{"x":1}', :headers => {"Etag" => "x"})
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
headers = response.headers
|
8
|
+
first_response = client.connection.get("blergh")
|
9
|
+
first_response.status.should == 200
|
10
|
+
first_response.body.should == {"x"=>1}
|
13
11
|
|
14
12
|
stub_request(:get, %r{blergh}).to_return(:status => 304, :headers => {"Etag" => "x"})
|
15
13
|
response = client.connection.get("blergh")
|
16
14
|
response.status.should == 304
|
17
15
|
response.body.should == {"x"=>1}
|
18
|
-
|
16
|
+
|
17
|
+
%w{content_type content_length etag}.each do |header|
|
18
|
+
response.headers[header].should == first_response.headers[header]
|
19
|
+
end
|
19
20
|
end
|
20
21
|
end
|
data/spec/core/spec_helper.rb
CHANGED
@@ -73,7 +73,7 @@ module TestHelper
|
|
73
73
|
|
74
74
|
def stub_json_request(verb, path_matcher, body = json, options = {})
|
75
75
|
stub_request(verb, path_matcher).to_return(Hashie::Mash.new(
|
76
|
-
:body => body, :headers => { :content_type => "application/json" }
|
76
|
+
:body => body, :headers => { :content_type => "application/json", :content_length => body.size }
|
77
77
|
).deep_merge(options))
|
78
78
|
end
|
79
79
|
end
|