| @@ -11,6 +11,16 @@ class AppTest < MiniTest::Spec · 10 unmodified lines |
| 11 | 11 | App |
| 12 | 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 | 24 | describe "/" do |
| 15 | 25 | it "works" do |
| 16 | 26 | get '/' |
| @@ -20,13 +30,13 @@ class AppTest < MiniTest::Spec · 3 unmodified lines |
| 20 | 30 | it "redirects to /#q= when there is a 'q' query param" do |
| 21 | 31 | get '/search', q: 'foo' |
| 22 | 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 | 34 | end |
| 25 | 35 | |
| 26 | 36 | it "redirects without the query string" do |
| 27 | 37 | get '/', foo: 'bar' |
| 28 | 38 | assert last_response.redirect? |
| 29 | | − assert_equal 'http://example.org/', last_response['Location'] |
| 39 | + assert_equal 'https://example.org/', last_response['Location'] |
| 30 | 40 | end |
| 31 | 41 | |
| 32 | 42 | it "sets default size" do |
| @@ -52,7 +62,7 @@ class AppTest < MiniTest::Spec · 19 unmodified lines |
| 52 | 62 | %w(offline about news help).each do |page| |
| 53 | 63 | get "/#{page}", {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 54 | 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 | 66 | end |
| 57 | 67 | end |
| 58 | 68 | |
| @@ -61,7 +71,7 @@ class AppTest < MiniTest::Spec · 2 unmodified lines |
| 61 | 71 | set_cookie('foo=bar') |
| 62 | 72 | get "/#{page}", {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 63 | 73 | assert last_response.redirect? |
| 64 | | − assert_equal 'http://example.org/', last_response['Location'] |
| 74 | + assert_equal 'https://example.org/', last_response['Location'] |
| 65 | 75 | assert last_response['Set-Cookie'].start_with?("initial_path=%2F#{page}; path=/; expires=") |
| 66 | 76 | end |
| 67 | 77 | end |
| @@ -71,11 +81,11 @@ class AppTest < MiniTest::Spec · 3 unmodified lines |
| 71 | 81 | it "redirects to /#q=" do |
| 72 | 82 | get '/search' |
| 73 | 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 | 86 | get '/search', q: 'foo' |
| 77 | 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 | 89 | end |
| 80 | 90 | end |
| 81 | 91 | |
| @@ -148,7 +158,7 @@ class AppTest < MiniTest::Spec · 66 unmodified lines |
| 148 | 158 | set_cookie('docs=html~5') |
| 149 | 159 | get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 150 | 160 | assert last_response.redirect? |
| 151 | | − assert_equal 'http://example.org/', last_response['Location'] |
| 161 | + assert_equal 'https://example.org/', last_response['Location'] |
| 152 | 162 | assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7E5%2F; path=/; expires=") |
| 153 | 163 | end |
| 154 | 164 | |
| @@ -161,13 +171,13 @@ class AppTest < MiniTest::Spec · 6 unmodified lines |
| 161 | 171 | set_cookie('docs=html~5') |
| 162 | 172 | get '/html/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 163 | 173 | assert last_response.redirect? |
| 164 | | − assert_equal 'http://example.org/', last_response['Location'] |
| 174 | + assert_equal 'https://example.org/', last_response['Location'] |
| 165 | 175 | assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%2F; path=/; expires=") |
| 166 | 176 | end |
| 167 | 177 | |
| 168 | 178 | it "renders when the doc exists and is enabled, and the request is from Googlebot" do |
| 169 | 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 | 181 | assert last_response.ok? |
| 172 | 182 | end |
| 173 | 183 | |
| @@ -187,17 +197,17 @@ class AppTest < MiniTest::Spec · 13 unmodified lines |
| 187 | 197 | it "redirects with trailing slash" do |
| 188 | 198 | get '/html' |
| 189 | 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 | 202 | get '/html', bar: 'baz' |
| 193 | 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 | 205 | end |
| 196 | 206 | |
| 197 | 207 | it "redirects old docs" do |
| 198 | 208 | get '/iojs/' |
| 199 | 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 | 211 | end |
| 202 | 212 | end |
| 203 | 213 | |
| @@ -232,17 +242,17 @@ class AppTest < MiniTest::Spec · 28 unmodified lines |
| 232 | 242 | it "redirects with trailing slash" do |
| 233 | 243 | get '/css-foo' |
| 234 | 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 | 247 | get '/css-foo', bar: 'baz' |
| 238 | 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 | 250 | end |
| 241 | 251 | |
| 242 | 252 | it "redirects old docs" do |
| 243 | 253 | get '/yii1-foo/' |
| 244 | 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 | 256 | end |
| 247 | 257 | end |
| 248 | 258 | |
| @@ -263,17 +273,17 @@ class AppTest < MiniTest::Spec · 14 unmodified lines |
| 263 | 273 | it "redirects without trailing slash" do |
| 264 | 274 | get '/css/foo/' |
| 265 | 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 | 278 | get '/css/foo/', bar: 'baz' |
| 269 | 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 | 281 | end |
| 272 | 282 | |
| 273 | 283 | it "redirects old docs" do |
| 274 | 284 | get '/python2/foo' |
| 275 | 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 | 287 | end |
| 278 | 288 | end |
| 279 | 289 | |
| @@ -281,7 +291,7 @@ class AppTest < MiniTest::Spec · 1 unmodified line |
| 281 | 291 | it "returns to the asset path" do |
| 282 | 292 | get '/docs.json' |
| 283 | 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 | 295 | end |
| 286 | 296 | end |
| 287 | 297 | |
| @@ -289,7 +299,7 @@ class AppTest < MiniTest::Spec · 1 unmodified line |
| 289 | 299 | it "returns to the asset path" do |
| 290 | 300 | get '/application.js' |
| 291 | 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 | 303 | end |
| 294 | 304 | end |
| 295 | 305 | |
| @@ -297,7 +307,7 @@ class AppTest < MiniTest::Spec · 1 unmodified line |
| 297 | 307 | it "returns to the asset path" do |
| 298 | 308 | get '/application.css' |
| 299 | 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 | 311 | end |
| 302 | 312 | end |
| 303 | 313 | |