]> git.openstreetmap.org Git - rails.git/commitdiff
Pass correct headers to requests
authorTom Hughes <tom@compton.nu>
Fri, 11 Apr 2025 23:09:27 +0000 (00:09 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 15 Apr 2025 17:26:21 +0000 (18:26 +0100)
Let rack convert to the internal names instead of using them
directly and bypassing some of the internals.

test/integration/compressed_requests_test.rb
test/integration/cors_test.rb
test/integration/page_locale_test.rb

index 3f6f13cc9ae39a38058a4dd27c15363e8cb3f92b..372d2dfe1956dd05c05ff0fe04e139cb4ee21a8b 100644 (file)
@@ -38,7 +38,7 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => diff,
          :headers => bearer_authorization_header(user).merge(
-           "HTTP_CONTENT_TYPE" => "application/xml"
+           "Content-Type" => "application/xml"
          )
     assert_response :success,
                     "can't upload an uncompressed diff to changeset: #{@response.body}"
@@ -86,8 +86,8 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => gzip_content(diff),
          :headers => bearer_authorization_header(user).merge(
-           "HTTP_CONTENT_ENCODING" => "gzip",
-           "HTTP_CONTENT_TYPE" => "application/xml"
+           "Content-Encoding" => "gzip",
+           "Content-Type" => "application/xml"
          )
     assert_response :success,
                     "can't upload a gzip compressed diff to changeset: #{@response.body}"
@@ -135,8 +135,8 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => deflate_content(diff),
          :headers => bearer_authorization_header(user).merge(
-           "HTTP_CONTENT_ENCODING" => "deflate",
-           "HTTP_CONTENT_TYPE" => "application/xml"
+           "Content-Encoding" => "deflate",
+           "Content-Type" => "application/xml"
          )
     assert_response :success,
                     "can't upload a deflate compressed diff to changeset: #{@response.body}"
@@ -155,8 +155,8 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => "",
          :headers => bearer_authorization_header(user).merge(
-           "HTTP_CONTENT_ENCODING" => "unknown",
-           "HTTP_CONTENT_TYPE" => "application/xml"
+           "Content-Encoding" => "unknown",
+           "Content-Type" => "application/xml"
          )
     assert_response :unsupported_media_type
   end
index c35f73d349d7c90f415d73c6e7935feabafeb8c2..88201231befe300fe33a74da63e89fdec178dd29 100644 (file)
@@ -3,8 +3,8 @@ require "test_helper"
 class CORSTest < ActionDispatch::IntegrationTest
   def test_api_routes_allow_cross_origin_requests
     process :options, "/api/capabilities", :headers => {
-      "HTTP_ORIGIN" => "http://www.example.com",
-      "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET"
+      "Origin" => "http://www.example.com",
+      "Access-Control-Request-Method" => "GET"
     }
 
     assert_response :success
@@ -15,8 +15,8 @@ class CORSTest < ActionDispatch::IntegrationTest
 
   def test_non_api_routes_dont_allow_cross_origin_requests
     process :options, "/", :headers => {
-      "HTTP_ORIGIN" => "http://www.example.com",
-      "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET"
+      "Origin" => "http://www.example.com",
+      "Access-Control-Request-Method" => "GET"
     }
 
     assert_response :success
index 6f6d7779fc3ab420cb5f5a670254c3f2c5b523cc..b2f782d30ab4722a6b2447fbfe9a8094b941d210 100644 (file)
@@ -14,7 +14,7 @@ class PageLocaleTest < ActionDispatch::IntegrationTest
       assert_empty User.find(user.id).languages
       assert_select "html[lang=?]", "en"
 
-      get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" }
+      get "/diary/new", :headers => { "Accept-Language" => "fr, en" }
       assert_equal %w[fr en], User.find(user.id).languages
       assert_select "html[lang=?]", "fr"
     end