Merge branch '8784-dir-listings'
[arvados.git] / services / api / test / integration / errors_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class ErrorsTest < ActionDispatch::IntegrationTest
8   fixtures :api_client_authorizations
9
10   %w(/arvados/v1/shoes /arvados/shoes /shoes /nodes /users).each do |path|
11     test "non-existent route #{path}" do
12       get path, {:format => :json}, auth(:active)
13       assert_nil assigns(:objects)
14       assert_nil assigns(:object)
15       assert_not_nil json_response['errors']
16       assert_response 404
17     end
18   end
19
20   n=0
21   Rails.application.routes.routes.each do |route|
22     test "route #{n += 1} '#{route.path.spec.to_s}' is not an accident" do
23       # Generally, new routes should appear under /arvados/v1/. If
24       # they appear elsewhere, that might have been caused by default
25       # rails generator behavior that we don't want.
26       assert_match(/^\/(|\*a|arvados\/v1\/.*|auth\/.*|login|logout|database\/reset|discovery\/.*|static\/.*|themes\/.*|assets)(\(\.:format\))?$/,
27                    route.path.spec.to_s,
28                    "Unexpected new route: #{route.path.spec}")
29     end
30   end
31 end