]> git.openstreetmap.org Git - rails.git/commitdiff
Update rack-cors and fix tests for changes in behaviour
authorTom Hughes <tom@compton.nu>
Mon, 31 Jul 2017 20:55:01 +0000 (21:55 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 31 Jul 2017 20:55:01 +0000 (21:55 +0100)
Gemfile.lock
test/integration/cors_test.rb

index 9b79e9ca14db7d80ba66ee285a570a9d5031f097..dce7203ca9aeea67b56c32465f0ad8a15b2172ab 100644 (file)
@@ -225,7 +225,7 @@ GEM
     public_suffix (2.0.5)
     r2 (0.2.6)
     rack (2.0.3)
-    rack-cors (0.4.1)
+    rack-cors (1.0.1)
     rack-openid (1.3.1)
       rack (>= 1.1.0)
       ruby-openid (>= 2.1.8)
index 05754da7185d4735c9a95796b98377e3befdfeee..9ff7e360e50f1c903342e293da2659dfe2706c23 100644 (file)
@@ -8,15 +8,20 @@ class CORSTest < ActionDispatch::IntegrationTest
     }
 
     assert_response :success
-    assert_equal "http://www.example.com", response.headers["Access-Control-Allow-Origin"]
+    assert_equal "*", response.headers["Access-Control-Allow-Origin"]
+    assert_equal "text/plain", response.content_type
+    assert_equal "", response.body
   end
 
   def test_non_api_routes_dont_allow_cross_origin_requests
-    assert_raises ActionController::RoutingError do
-      process :options, "/", :headers => {
-        "HTTP_ORIGIN" => "http://www.example.com",
-        "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET"
-      }
-    end
+    process :options, "/", :headers => {
+      "HTTP_ORIGIN" => "http://www.example.com",
+      "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET"
+    }
+
+    assert_response :success
+    assert_nil response.headers["Access-Control-Allow-Origin"]
+    assert_nil response.content_type
+    assert_equal "", response.body
   end
 end