seojs 0.0.7 → 0.0.8
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/seojs/middleware.rb +6 -1
- data/seojs.gemspec +1 -1
- data/test/test_middleware.rb +14 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ad9b187fe3b62bee1d5100414497a191a87208b
|
4
|
+
data.tar.gz: 85ee43ec276a28e5f45565ac327de2aff1003c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd35276ad55de901d5c39bbdc8e5f282bc3f835edde09b9e995da82f3d6d6679cccb67014065a490123ce154f2b9eca2ac4d8558929f74d1a2df2c063dcf47f0
|
7
|
+
data.tar.gz: 7cd786888c498b7f1abd96e6288177aa95cab8b2872d55292cf96841748490363166b691edd569cc65a68568506aad5a5a88539d2ac85e4da2cf160b1aa174d5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/seojs/middleware.rb
CHANGED
@@ -37,7 +37,12 @@ module Seojs
|
|
37
37
|
if [200, 301, 302, 304].include? snapshot_response.code.to_i
|
38
38
|
body = snapshot_response.body || ""
|
39
39
|
body = [body] unless body.respond_to?(:each)
|
40
|
-
|
40
|
+
headers = snapshot_response.to_hash
|
41
|
+
headers.each_key do |k|
|
42
|
+
v = headers[k]
|
43
|
+
headers[k] = v.join(', ') if v.kind_of? Array
|
44
|
+
end
|
45
|
+
[snapshot_response.code, headers, body]
|
41
46
|
else
|
42
47
|
nil
|
43
48
|
end
|
data/seojs.gemspec
CHANGED
data/test/test_middleware.rb
CHANGED
@@ -40,12 +40,21 @@ class TestMiddleware < Test::Unit::TestCase
|
|
40
40
|
assert last_response.ok?
|
41
41
|
end
|
42
42
|
|
43
|
+
def build_response(body, code, headers)
|
44
|
+
r = Net::HTTPResponse.new(1.0, code, "body")
|
45
|
+
headers.each_pair do |k,v|
|
46
|
+
r.add_field(k,v)
|
47
|
+
end
|
48
|
+
r.stubs(:body => body)
|
49
|
+
r
|
50
|
+
end
|
51
|
+
|
43
52
|
def test_forward_with_token
|
44
53
|
Seojs.token = 'token'
|
45
54
|
Net::HTTP::Get.expects(:new)
|
46
55
|
.with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
|
47
56
|
Net::HTTP.expects(:start)
|
48
|
-
.returns(
|
57
|
+
.returns(build_response('Snapshot!', 200, {}))
|
49
58
|
get '/hi', :_escaped_fragment_ => ''
|
50
59
|
assert last_response.ok?
|
51
60
|
assert_equal 'Snapshot!', last_response.body
|
@@ -65,9 +74,9 @@ class TestMiddleware < Test::Unit::TestCase
|
|
65
74
|
.with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
|
66
75
|
.returns({})
|
67
76
|
Net::HTTP.expects(:start)
|
68
|
-
.returns(
|
77
|
+
.returns(build_response('Snapshot!', 200, {'ETAG'=>'abc'}))
|
69
78
|
get '/hi', {:_escaped_fragment_ => ''}, {'HTTP_IF_NONE_MATCH' => '123'}
|
70
|
-
|
79
|
+
assert_equal 'abc', last_response.headers['ETAG']
|
71
80
|
assert last_response.ok?
|
72
81
|
assert_equal 'Snapshot!', last_response.body
|
73
82
|
end
|
@@ -77,7 +86,7 @@ class TestMiddleware < Test::Unit::TestCase
|
|
77
86
|
Net::HTTP::Get.expects(:new)
|
78
87
|
.with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
|
79
88
|
Net::HTTP.expects(:start)
|
80
|
-
.returns(
|
89
|
+
.returns(build_response('not found...', 404, {}))
|
81
90
|
get '/hi', :_escaped_fragment_ => ''
|
82
91
|
assert last_response.ok?
|
83
92
|
assert_equal 'Hello!', last_response.body
|
@@ -88,7 +97,7 @@ class TestMiddleware < Test::Unit::TestCase
|
|
88
97
|
Net::HTTP::Get.expects(:new)
|
89
98
|
.with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
|
90
99
|
Net::HTTP.expects(:start)
|
91
|
-
.returns(
|
100
|
+
.returns(build_response('somewhere else', 302, {'Location' => 'http://google.com/'}))
|
92
101
|
get '/hi', :_escaped_fragment_ => ''
|
93
102
|
assert last_response.redirect?
|
94
103
|
follow_redirect!
|