diff options
author | schneems <richard.schneeman@gmail.com> | 2014-08-21 11:52:25 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2014-08-24 15:58:16 -0500 |
commit | 8e31fa3b72892f7421b85b5a79d71a2d726ccddd (patch) | |
tree | 71d23ce8d085e453d0ae4c3538b49d161ead5588 /actionpack/test/dispatch/static_test.rb | |
parent | 33c05363e2ed52aa8bdbf5ebf9ee5226ab85ecbc (diff) | |
download | rails-8e31fa3b72892f7421b85b5a79d71a2d726ccddd.tar.gz rails-8e31fa3b72892f7421b85b5a79d71a2d726ccddd.tar.bz2 rails-8e31fa3b72892f7421b85b5a79d71a2d726ccddd.zip |
Address comments on Gzip implementation
- don't mutate PATH_INFO in env, test
- test fallback content type matches Rack::File
- change assertion style
- make HTTP_ACCEPT_ENCODING comparison case insensitive
- return gzip path from method instead of true/false so we don't have to assume later
- don't allocate un-needed hash.
Original comments:
https://github.com/rails/rails/commit/
cfaaacd9763642e91761de54c90669a88d772e5a#commitcomment-7468728
cc @jeremy
Diffstat (limited to 'actionpack/test/dispatch/static_test.rb')
-rw-r--r-- | actionpack/test/dispatch/static_test.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index f4b3a8cb93..97affc7b21 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -115,8 +115,30 @@ module StaticTests assert_equal 'Accept-Encoding', response.headers["Vary"] assert_equal 'gzip', response.headers["Content-Encoding"] + response = get(file_name, 'HTTP_ACCEPT_ENCODING' => 'Gzip') + assert_gzip file_name, response + + response = get(file_name, 'HTTP_ACCEPT_ENCODING' => 'GZIP') + assert_gzip file_name, response + response = get(file_name, 'HTTP_ACCEPT_ENCODING' => '') - refute_equal 'gzip', response.headers["Content-Encoding"] + assert_not_equal 'gzip', response.headers["Content-Encoding"] + end + + def test_does_not_modify_path_info + file_name = "/gzip/application-a71b3024f80aea3181c09774ca17e712.js" + env = {'PATH_INFO' => file_name, 'HTTP_ACCEPT_ENCODING' => 'gzip'} + @app.call(env) + assert_equal file_name, env['PATH_INFO'] + end + + def test_serves_gzip_with_propper_content_type_fallback + file_name = "/gzip/foo.zoo" + response = get(file_name, 'HTTP_ACCEPT_ENCODING' => 'gzip') + assert_gzip file_name, response + + default_response = get(file_name) # no gzip + assert_equal default_response.headers['Content-Type'], response.headers['Content-Type'] end # Windows doesn't allow \ / : * ? " < > | in filenames @@ -147,7 +169,7 @@ module StaticTests def assert_html(body, response) assert_equal body, response.body assert_equal "text/html", response.headers["Content-Type"] - refute response.headers.key?("Vary") + assert_nil response.headers["Vary"] end def get(path, headers = {}) |