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"
10 assert_response :success
11 assert_equal "http://www.example.com", response.headers["Access-Control-Allow-Origin"]
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"