Merge branch '13561-trashed-collection-versions-fix'
[arvados.git] / services / api / test / unit / job_test.rb
index e0a4f84614dba35fa7493427d89d88fa1f875d77..fc6a97cf7480c645206c867e3449822bfcfa41a5 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'test_helper'
 require 'helpers/git_test_helper'
 require 'helpers/docker_migration_helper'
@@ -641,4 +645,32 @@ class JobTest < ActiveSupport::TestCase
     child = Job.find_by_uuid job.components.collect{|_, uuid| uuid}[0]
     assert_equal Job::Cancelled, child.state
   end
+
+  test 'enable legacy api configuration option = true' do
+    Rails.configuration.enable_legacy_jobs_api = true
+    check_enable_legacy_jobs_api
+    assert_equal [], Rails.configuration.disable_api_methods
+  end
+
+  test 'enable legacy api configuration option = false' do
+    Rails.configuration.enable_legacy_jobs_api = false
+    check_enable_legacy_jobs_api
+    assert_equal Disable_jobs_api_method_list, Rails.configuration.disable_api_methods
+  end
+
+  test 'enable legacy api configuration option = auto, has jobs' do
+    Rails.configuration.enable_legacy_jobs_api = "auto"
+    check_enable_legacy_jobs_api
+    assert_equal [], Rails.configuration.disable_api_methods
+  end
+
+  test 'enable legacy api configuration option = auto, no jobs' do
+    Rails.configuration.enable_legacy_jobs_api = "auto"
+    act_as_system_user do
+      Job.destroy_all
+    end
+    puts "ZZZ #{Job.count}"
+    check_enable_legacy_jobs_api
+    assert_equal Disable_jobs_api_method_list, Rails.configuration.disable_api_methods
+  end
 end