From: Tom Hughes Date: Mon, 31 Jul 2017 20:55:01 +0000 (+0100) Subject: Update rack-cors and fix tests for changes in behaviour X-Git-Tag: live~3312 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/8c513beec6b15fc3a61a05e4ed868b23c5f94be8?ds=sidebyside Update rack-cors and fix tests for changes in behaviour --- diff --git a/Gemfile.lock b/Gemfile.lock index 9b79e9ca1..dce7203ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/test/integration/cors_test.rb b/test/integration/cors_test.rb index 05754da71..9ff7e360e 100644 --- a/test/integration/cors_test.rb +++ b/test/integration/cors_test.rb @@ -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