zendesk_api 0.3.8 → 0.3.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.
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- zendesk_api (0.3.8)
10
+ zendesk_api (0.3.9)
11
11
  faraday (>= 0.8.0)
12
12
  faraday_middleware (>= 0.8.7)
13
13
  hashie (>= 1.2)
@@ -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.merge!(:body => cached[:body], :response_headers => cached[:response_headers])
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
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -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
- response = client.connection.get("blergh")
9
- response.status.should == 200
10
- response.body.should == {"x"=>1}
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
- response.headers.should == headers
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: