| @@ -11,6 +11,16 @@ class AppTest < MiniTest::Spec · 10 unmodified lines |
| 11 | App | 11 | App |
| 12 | end | 12 | end |
| 13 | | 13 | |
| | 14 | before do |
| | 15 | current_session.env('HTTPS', 'on') |
| | 16 | end |
| | 17 | |
| | 18 | it 'redirects to HTTPS' do |
| | 19 | get 'http://example.com/test?q=1', {}, 'HTTPS' => 'off' |
| | 20 | assert last_response.redirect? |
| | 21 | assert_equal 'https://example.com/test?q=1', last_response['Location'] |
| | 22 | end |
| | 23 | |
| 14 | describe "/" do | 24 | describe "/" do |
| 15 | it "works" do | 25 | it "works" do |
| 16 | get '/' | 26 | get '/' |
| @@ -20,13 +30,13 @@ class AppTest < MiniTest::Spec · 3 unmodified lines |
| 20 | it "redirects to /#q= when there is a 'q' query param" do | 30 | it "redirects to /#q= when there is a 'q' query param" do |
| 21 | get '/search', q: 'foo' | 31 | get '/search', q: 'foo' |
| 22 | assert last_response.redirect? | 32 | assert last_response.redirect? |
| 23 | assert_equal 'http://example.org/#q=foo', last_response['Location'] | 33 | assert_equal 'https://example.org/#q=foo', last_response['Location'] |
| 24 | end | 34 | end |
| 25 | | 35 | |
| 26 | it "redirects without the query string" do | 36 | it "redirects without the query string" do |
| 27 | get '/', foo: 'bar' | 37 | get '/', foo: 'bar' |
| 28 | assert last_response.redirect? | 38 | assert last_response.redirect? |
| 29 | assert_equal 'http://example.org/', last_response['Location'] | 39 | assert_equal 'https://example.org/', last_response['Location'] |
| 30 | end | 40 | end |
| 31 | | 41 | |
| 32 | it "sets default size" do | 42 | it "sets default size" do |
| @@ -52,7 +62,7 @@ class AppTest < MiniTest::Spec · 19 unmodified lines |
| 52 | %w(offline about news help).each do |page| | 62 | %w(offline about news help).each do |page| |
| 53 | get "/#{page}", {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | 63 | get "/#{page}", {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 54 | assert last_response.redirect? | 64 | assert last_response.redirect? |
| 55 | assert_equal "http://example.org/#/#{page}", last_response['Location'] | 65 | assert_equal "https://example.org/#/#{page}", last_response['Location'] |
| 56 | end | 66 | end |
| 57 | end | 67 | end |
| 58 | | 68 | |
| @@ -61,7 +71,7 @@ class AppTest < MiniTest::Spec · 2 unmodified lines |
| 61 | set_cookie('foo=bar') | 71 | set_cookie('foo=bar') |
| 62 | get "/#{page}", {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | 72 | get "/#{page}", {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 63 | assert last_response.redirect? | 73 | assert last_response.redirect? |
| 64 | assert_equal 'http://example.org/', last_response['Location'] | 74 | assert_equal 'https://example.org/', last_response['Location'] |
| 65 | assert last_response['Set-Cookie'].start_with?("initial_path=%2F#{page}; path=/; expires=") | 75 | assert last_response['Set-Cookie'].start_with?("initial_path=%2F#{page}; path=/; expires=") |
| 66 | end | 76 | end |
| 67 | end | 77 | end |
| @@ -71,11 +81,11 @@ class AppTest < MiniTest::Spec · 3 unmodified lines |
| 71 | it "redirects to /#q=" do | 81 | it "redirects to /#q=" do |
| 72 | get '/search' | 82 | get '/search' |
| 73 | assert last_response.redirect? | 83 | assert last_response.redirect? |
| 74 | assert_equal 'http://example.org/#q=', last_response['Location'] | 84 | assert_equal 'https://example.org/#q=', last_response['Location'] |
| 75 | | 85 | |
| 76 | get '/search', q: 'foo' | 86 | get '/search', q: 'foo' |
| 77 | assert last_response.redirect? | 87 | assert last_response.redirect? |
| 78 | assert_equal 'http://example.org/#q=foo', last_response['Location'] | 88 | assert_equal 'https://example.org/#q=foo', last_response['Location'] |
| 79 | end | 89 | end |
| 80 | end | 90 | end |
| 81 | | 91 | |
| @@ -148,7 +158,7 @@ class AppTest < MiniTest::Spec · 66 unmodified lines |
| 148 | set_cookie('docs=html~5') | 158 | set_cookie('docs=html~5') |
| 149 | get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | 159 | get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 150 | assert last_response.redirect? | 160 | assert last_response.redirect? |
| 151 | assert_equal 'http://example.org/', last_response['Location'] | 161 | assert_equal 'https://example.org/', last_response['Location'] |
| 152 | assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7E5%2F; path=/; expires=") | 162 | assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7E5%2F; path=/; expires=") |
| 153 | end | 163 | end |
| 154 | | 164 | |
| @@ -161,13 +171,13 @@ class AppTest < MiniTest::Spec · 6 unmodified lines |
| 161 | set_cookie('docs=html~5') | 171 | set_cookie('docs=html~5') |
| 162 | get '/html/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | 172 | get '/html/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 163 | assert last_response.redirect? | 173 | assert last_response.redirect? |
| 164 | assert_equal 'http://example.org/', last_response['Location'] | 174 | assert_equal 'https://example.org/', last_response['Location'] |
| 165 | assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%2F; path=/; expires=") | 175 | assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%2F; path=/; expires=") |
| 166 | end | 176 | end |
| 167 | | 177 | |
| 168 | it "renders when the doc exists and is enabled, and the request is from Googlebot" do | 178 | it "renders when the doc exists and is enabled, and the request is from Googlebot" do |
| 169 | set_cookie('docs=html') | 179 | set_cookie('docs=html') |
| 170 | get '/html/', {}, 'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' | 180 | get '/html/', {}, 'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Googlebot/2.1; +https://www.google.com/bot.html)' |
| 171 | assert last_response.ok? | 181 | assert last_response.ok? |
| 172 | end | 182 | end |
| 173 | | 183 | |
| @@ -187,17 +197,17 @@ class AppTest < MiniTest::Spec · 13 unmodified lines |
| 187 | it "redirects with trailing slash" do | 197 | it "redirects with trailing slash" do |
| 188 | get '/html' | 198 | get '/html' |
| 189 | assert last_response.redirect? | 199 | assert last_response.redirect? |
| 190 | assert_equal 'http://example.org/html/', last_response['Location'] | 200 | assert_equal 'https://example.org/html/', last_response['Location'] |
| 191 | | 201 | |
| 192 | get '/html', bar: 'baz' | 202 | get '/html', bar: 'baz' |
| 193 | assert last_response.redirect? | 203 | assert last_response.redirect? |
| 194 | assert_equal 'http://example.org/html/?bar=baz', last_response['Location'] | 204 | assert_equal 'https://example.org/html/?bar=baz', last_response['Location'] |
| 195 | end | 205 | end |
| 196 | | 206 | |
| 197 | it "redirects old docs" do | 207 | it "redirects old docs" do |
| 198 | get '/iojs/' | 208 | get '/iojs/' |
| 199 | assert last_response.redirect? | 209 | assert last_response.redirect? |
| 200 | assert_equal 'http://example.org/node/', last_response['Location'] | 210 | assert_equal 'https://example.org/node/', last_response['Location'] |
| 201 | end | 211 | end |
| 202 | end | 212 | end |
| 203 | | 213 | |
| @@ -232,17 +242,17 @@ class AppTest < MiniTest::Spec · 28 unmodified lines |
| 232 | it "redirects with trailing slash" do | 242 | it "redirects with trailing slash" do |
| 233 | get '/css-foo' | 243 | get '/css-foo' |
| 234 | assert last_response.redirect? | 244 | assert last_response.redirect? |
| 235 | assert_equal 'http://example.org/css-foo/', last_response['Location'] | 245 | assert_equal 'https://example.org/css-foo/', last_response['Location'] |
| 236 | | 246 | |
| 237 | get '/css-foo', bar: 'baz' | 247 | get '/css-foo', bar: 'baz' |
| 238 | assert last_response.redirect? | 248 | assert last_response.redirect? |
| 239 | assert_equal 'http://example.org/css-foo/?bar=baz', last_response['Location'] | 249 | assert_equal 'https://example.org/css-foo/?bar=baz', last_response['Location'] |
| 240 | end | 250 | end |
| 241 | | 251 | |
| 242 | it "redirects old docs" do | 252 | it "redirects old docs" do |
| 243 | get '/yii1-foo/' | 253 | get '/yii1-foo/' |
| 244 | assert last_response.redirect? | 254 | assert last_response.redirect? |
| 245 | assert_equal 'http://example.org/yii~1.1-foo/', last_response['Location'] | 255 | assert_equal 'https://example.org/yii~1.1-foo/', last_response['Location'] |
| 246 | end | 256 | end |
| 247 | end | 257 | end |
| 248 | | 258 | |
| @@ -263,17 +273,17 @@ class AppTest < MiniTest::Spec · 14 unmodified lines |
| 263 | it "redirects without trailing slash" do | 273 | it "redirects without trailing slash" do |
| 264 | get '/css/foo/' | 274 | get '/css/foo/' |
| 265 | assert last_response.redirect? | 275 | assert last_response.redirect? |
| 266 | assert_equal 'http://example.org/css/foo', last_response['Location'] | 276 | assert_equal 'https://example.org/css/foo', last_response['Location'] |
| 267 | | 277 | |
| 268 | get '/css/foo/', bar: 'baz' | 278 | get '/css/foo/', bar: 'baz' |
| 269 | assert last_response.redirect? | 279 | assert last_response.redirect? |
| 270 | assert_equal 'http://example.org/css/foo?bar=baz', last_response['Location'] | 280 | assert_equal 'https://example.org/css/foo?bar=baz', last_response['Location'] |
| 271 | end | 281 | end |
| 272 | | 282 | |
| 273 | it "redirects old docs" do | 283 | it "redirects old docs" do |
| 274 | get '/python2/foo' | 284 | get '/python2/foo' |
| 275 | assert last_response.redirect? | 285 | assert last_response.redirect? |
| 276 | assert_equal 'http://example.org/python~2.7/foo', last_response['Location'] | 286 | assert_equal 'https://example.org/python~2.7/foo', last_response['Location'] |
| 277 | end | 287 | end |
| 278 | end | 288 | end |
| 279 | | 289 | |
| @@ -281,7 +291,7 @@ class AppTest < MiniTest::Spec · 1 unmodified line |
| 281 | it "returns to the asset path" do | 291 | it "returns to the asset path" do |
| 282 | get '/docs.json' | 292 | get '/docs.json' |
| 283 | assert last_response.redirect? | 293 | assert last_response.redirect? |
| 284 | assert_equal 'http://example.org/assets/docs.json', last_response['Location'] | 294 | assert_equal 'https://example.org/assets/docs.json', last_response['Location'] |
| 285 | end | 295 | end |
| 286 | end | 296 | end |
| 287 | | 297 | |
| @@ -289,7 +299,7 @@ class AppTest < MiniTest::Spec · 1 unmodified line |
| 289 | it "returns to the asset path" do | 299 | it "returns to the asset path" do |
| 290 | get '/application.js' | 300 | get '/application.js' |
| 291 | assert last_response.redirect? | 301 | assert last_response.redirect? |
| 292 | assert_equal 'http://example.org/assets/application.js', last_response['Location'] | 302 | assert_equal 'https://example.org/assets/application.js', last_response['Location'] |
| 293 | end | 303 | end |
| 294 | end | 304 | end |
| 295 | | 305 | |
| @@ -297,7 +307,7 @@ class AppTest < MiniTest::Spec · 1 unmodified line |
| 297 | it "returns to the asset path" do | 307 | it "returns to the asset path" do |
| 298 | get '/application.css' | 308 | get '/application.css' |
| 299 | assert last_response.redirect? | 309 | assert last_response.redirect? |
| 300 | assert_equal 'http://example.org/assets/application.css', last_response['Location'] | 310 | assert_equal 'https://example.org/assets/application.css', last_response['Location'] |
| 301 | end | 311 | end |
| 302 | end | 312 | end |
| 303 | | 313 | |