]> git.openstreetmap.org Git - rails.git/blobdiff - test/integration/compressed_requests_test.rb
Use fenced code blocks
[rails.git] / test / integration / compressed_requests_test.rb
index 6ea875a9d482b8f911b07497f299b21c166fead8..3f6f13cc9ae39a38058a4dd27c15363e8cb3f92b 100644 (file)
@@ -16,7 +16,7 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest
 
     # simple diff to change a node, way and relation by removing
     # their tags
-    diff = <<CHANGESET.strip_heredoc
+    diff = <<~CHANGESET
       <osmChange>
        <modify>
         <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
@@ -32,15 +32,14 @@ class CompressedRequestsTest < ActionDispatch::IntegrationTest
         </relation>
        </modify>
       </osmChange>
-CHANGESET
+    CHANGESET
 
     # upload it
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => diff,
-         :headers => {
-           "HTTP_AUTHORIZATION" => format("Basic %{auth}", :auth => Base64.encode64("#{user.display_name}:test")),
+         :headers => bearer_authorization_header(user).merge(
            "HTTP_CONTENT_TYPE" => "application/xml"
-         }
+         )
     assert_response :success,
                     "can't upload an uncompressed diff to changeset: #{@response.body}"
 
@@ -65,7 +64,7 @@ CHANGESET
 
     # simple diff to change a node, way and relation by removing
     # their tags
-    diff = <<CHANGESET.strip_heredoc
+    diff = <<~CHANGESET
       <osmChange>
        <modify>
         <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
@@ -81,16 +80,15 @@ CHANGESET
         </relation>
        </modify>
       </osmChange>
-CHANGESET
+    CHANGESET
 
     # upload it
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => gzip_content(diff),
-         :headers => {
-           "HTTP_AUTHORIZATION" => format("Basic %{auth}", :auth => Base64.encode64("#{user.display_name}:test")),
+         :headers => bearer_authorization_header(user).merge(
            "HTTP_CONTENT_ENCODING" => "gzip",
            "HTTP_CONTENT_TYPE" => "application/xml"
-         }
+         )
     assert_response :success,
                     "can't upload a gzip compressed diff to changeset: #{@response.body}"
 
@@ -115,7 +113,7 @@ CHANGESET
 
     # simple diff to change a node, way and relation by removing
     # their tags
-    diff = <<CHANGESET.strip_heredoc
+    diff = <<~CHANGESET
       <osmChange>
        <modify>
         <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
@@ -131,16 +129,15 @@ CHANGESET
         </relation>
        </modify>
       </osmChange>
-CHANGESET
+    CHANGESET
 
     # upload it
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => deflate_content(diff),
-         :headers => {
-           "HTTP_AUTHORIZATION" => format("Basic %{auth}", :auth => Base64.encode64("#{user.display_name}:test")),
+         :headers => bearer_authorization_header(user).merge(
            "HTTP_CONTENT_ENCODING" => "deflate",
            "HTTP_CONTENT_TYPE" => "application/xml"
-         }
+         )
     assert_response :success,
                     "can't upload a deflate compressed diff to changeset: #{@response.body}"
 
@@ -157,11 +154,10 @@ CHANGESET
     # upload it
     post "/api/0.6/changeset/#{changeset.id}/upload",
          :params => "",
-         :headers => {
-           "HTTP_AUTHORIZATION" => format("Basic %{auth}", :auth => Base64.encode64("#{user.display_name}:test")),
+         :headers => bearer_authorization_header(user).merge(
            "HTTP_CONTENT_ENCODING" => "unknown",
            "HTTP_CONTENT_TYPE" => "application/xml"
-         }
+         )
     assert_response :unsupported_media_type
   end