]> git.openstreetmap.org Git - rails.git/blob - test/integration/cors_test.rb
Use rails 5 version of redirect_back.
[rails.git] / test / integration / cors_test.rb
1 require "test_helper"
2
3 class CORSTest < ActionDispatch::IntegrationTest
4   def test_api_routes_allow_cross_origin_requests
5     process :options, "/api/capabilities", :headers => {
6       "HTTP_ORIGIN" => "http://www.example.com",
7       "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET"
8     }
9
10     assert_response :success
11     assert_equal "http://www.example.com", response.headers["Access-Control-Allow-Origin"]
12   end
13
14   def test_non_api_routes_dont_allow_cross_origin_requests
15     assert_raises ActionController::RoutingError do
16       process :options, "/", :headers => {
17         "HTTP_ORIGIN" => "http://www.example.com",
18         "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET"
19       }
20     end
21   end
22 end