prerender_rails 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1773ce49f7fc96e82cc3a4186c4c9eb51f3c2479
4
- data.tar.gz: 12ab0d5981038d66d85f5198e35f2592a46a2b74
3
+ metadata.gz: 91c89ada805265938a4f4ea9aa9e493ac9fd0b13
4
+ data.tar.gz: 12e9b6252304f4da14cc2fcafbaf3de25c5106e1
5
5
  SHA512:
6
- metadata.gz: cdabf0df7454ac647756a966a2f7d3eecafa04f26fa2d293e278722442d1aaa5fcefcb07d0859a5789b178b730b54d4053ecfc9c55a3777e8b0eddd3527ee7d8
7
- data.tar.gz: 52ffb587b5a76c393c44859477a693e675718d52f4ad180d9725f54b53ea28936cb2d9c5d6d0e75be28421c7041cc9ce4702e6a4fbf50c7e597657f3581ae4ea
6
+ metadata.gz: 856778b38a05608d8b13e974a5cb3fd2b4179d12e8d3589780c708debd306b74fef2b7308c4034a3c6a5dfeaaa90c059a470193366b5aef1a758806f84e60816
7
+ data.tar.gz: 75c20ebdc874090837787c384e22449b016468972a0574b6b64375dedd88fdb44acb515696774d3906bfec3d3fd4ba7dc8c998a3122a83b04ebd4a78de8cba52
@@ -68,7 +68,7 @@ module Rack
68
68
 
69
69
  cached_response = before_render(env)
70
70
 
71
- if cached_response && cached_response.is_a?(Rack::Response)
71
+ if cached_response
72
72
  return cached_response.finish
73
73
  end
74
74
 
@@ -170,6 +170,8 @@ module Rack
170
170
 
171
171
  if cached_render && cached_render.is_a?(String)
172
172
  Rack::Response.new(cached_render, 200, [])
173
+ elsif cached_render && cached_render.is_a?(Rack::Response)
174
+ cached_render
173
175
  else
174
176
  nil
175
177
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "0.1.10"
5
+ spec.version = "0.1.11"
6
6
  spec.authors = ["Todd Hooper"]
7
7
  spec.email = ["todd@collectiveip.com"]
8
8
  spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
@@ -117,14 +117,23 @@ describe Rack::Prerender do
117
117
  end
118
118
 
119
119
 
120
- it "should return a prerendered response returned from before_render" do
120
+ it "should return a prerendered response if a string is returned from before_render" do
121
121
  request = Rack::MockRequest.env_for "/", "HTTP_USER_AGENT" => bot
122
- stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
123
- response = Rack::Prerender.new(@app, before_render: Proc.new do |env| return '<html>cached</html>' end).call(request)
122
+ response = Rack::Prerender.new(@app, before_render: Proc.new do |env| '<html>cached</html>' end).call(request)
124
123
 
125
124
  assert_equal ["<html>cached</html>"], response[2].body
126
125
  end
127
126
 
127
+
128
+ it "should return a prerendered response if a response is returned from before_render" do
129
+ request = Rack::MockRequest.env_for "/", "HTTP_USER_AGENT" => bot
130
+ response = Rack::Prerender.new(@app, before_render: Proc.new do |env| Rack::Response.new('<html>cached2</html>', 200, { 'test' => 'test2Header'}) end).call(request)
131
+
132
+ assert_equal ["<html>cached2</html>"], response[2].body
133
+ assert_equal response[2].status, 200
134
+ assert_equal( { 'test' => 'test2Header', "Content-Length"=>"20"}, response[2].headers )
135
+ end
136
+
128
137
 
129
138
  describe '#buildApiUrl' do
130
139
  it "should build the correct api url with the default url" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prerender_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-18 00:00:00.000000000 Z
11
+ date: 2013-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack