3 class Arvados::V1::SchemaControllerTest < ActionController::TestCase
8 Rails.cache.delete 'arvados_v1_rest_discovery'
12 test "should get fresh discovery document" do
15 assert_response :success
16 discovery_doc = JSON.parse(@response.body)
17 assert_equal 'discovery#restDescription', discovery_doc['kind']
19 Time.now - MAX_SCHEMA_AGE.seconds < discovery_doc['generatedAt'],
20 "discovery document was generated >#{MAX_SCHEMA_AGE}s ago")
23 test "discovery document has defaultTrashLifetime" do
25 assert_response :success
26 discovery_doc = JSON.parse(@response.body)
27 assert_includes discovery_doc, 'defaultTrashLifetime'
28 assert_equal discovery_doc['defaultTrashLifetime'], Rails.application.config.default_trash_lifetime
31 test "discovery document has source_version" do
33 assert_response :success
34 discovery_doc = JSON.parse(@response.body)
35 assert_match(/^[0-9a-f]+(-modified)?$/, discovery_doc['source_version'])
38 test "discovery document overrides source_version with config" do
39 Rails.configuration.source_version = 'aaa888fff'
41 assert_response :success
42 discovery_doc = JSON.parse(@response.body)
43 assert_equal 'aaa888fff', discovery_doc['source_version']
46 test "empty disable_api_methods" do
48 assert_response :success
49 discovery_doc = JSON.parse(@response.body)
51 discovery_doc['resources']['jobs']['methods']['create']['httpMethod'])
54 test "non-empty disable_api_methods" do
55 Rails.configuration.disable_api_methods =
56 ['jobs.create', 'pipeline_instances.create', 'pipeline_templates.create']
58 assert_response :success
59 discovery_doc = JSON.parse(@response.body)
60 ['jobs', 'pipeline_instances', 'pipeline_templates'].each do |r|
61 refute_includes(discovery_doc['resources'][r]['methods'].keys(), 'create')