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 +4 -4
- data/lib/prerender_rails.rb +3 -1
- data/prerender_rails.gemspec +1 -1
- data/test/lib/prerender_rails.rb +12 -3
- 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: 91c89ada805265938a4f4ea9aa9e493ac9fd0b13
|
4
|
+
data.tar.gz: 12e9b6252304f4da14cc2fcafbaf3de25c5106e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856778b38a05608d8b13e974a5cb3fd2b4179d12e8d3589780c708debd306b74fef2b7308c4034a3c6a5dfeaaa90c059a470193366b5aef1a758806f84e60816
|
7
|
+
data.tar.gz: 75c20ebdc874090837787c384e22449b016468972a0574b6b64375dedd88fdb44acb515696774d3906bfec3d3fd4ba7dc8c998a3122a83b04ebd4a78de8cba52
|
data/lib/prerender_rails.rb
CHANGED
@@ -68,7 +68,7 @@ module Rack
|
|
68
68
|
|
69
69
|
cached_response = before_render(env)
|
70
70
|
|
71
|
-
if cached_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
|
data/prerender_rails.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "prerender_rails"
|
5
|
-
spec.version = "0.1.
|
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}
|
data/test/lib/prerender_rails.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
11
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|