[ARVADOS] created: 95bed05f8888fba7dffb4b409c22e6620153e1b9

Git user git at public.curoverse.com
Mon Nov 7 11:40:34 EST 2016


        at  95bed05f8888fba7dffb4b409c22e6620153e1b9 (commit)


commit 95bed05f8888fba7dffb4b409c22e6620153e1b9
Author: radhika <radhika at curoverse.com>
Date:   Mon Nov 7 11:40:05 2016 -0500

    10310: improve pipeline notifications to use api_exists

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 4d98a56..ee3d676 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -230,7 +230,7 @@ class ApplicationController < ActionController::Base
   helper_method :arvados_api_exists
   def arvados_api_exists ctrl, method
     if [:jobs, :job_tasks, :pipeline_instances, :pipeline_templates].include?(ctrl)
-      arvados_api_client.discovery[:resources][ctrl].andand[:methods].andand[method]
+      ctrl.to_s.classify.constantize.api_exists?(method)
     else
       true
     end
@@ -778,11 +778,11 @@ class ApplicationController < ActionController::Base
   }
 
   @@notification_tests.push lambda { |controller, current_user|
-    begin
+    if PipelineInstance.api_exists?(:index)
       PipelineInstance.limit(1).where(created_by: current_user.uuid).each do
         return nil
       end
-    rescue ArvadosApiClient::NotFoundException
+    else
       return nil
     end
     return lambda { |view|
diff --git a/apps/workbench/test/controllers/disabled_api_test.rb b/apps/workbench/test/controllers/disabled_api_test.rb
new file mode 100644
index 0000000..933acf6
--- /dev/null
+++ b/apps/workbench/test/controllers/disabled_api_test.rb
@@ -0,0 +1,27 @@
+require 'test_helper'
+require 'helpers/share_object_helper'
+
+class DisabledApiTest < ActionController::TestCase
+  [
+    [:admin, false],
+    [:admin, true],
+  ].each do |user, crunch2|
+    test "dashboard recent processes as #{user} with #{if crunch2 then 'crunch2' else 'crunch1' end}" do
+      @controller = ProjectsController.new
+
+      if crunch2
+        dd = ArvadosApiClient.new_or_current.discovery
+        dd[:resources][:pipeline_instances][:methods].delete(:index)
+        ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
+      end
+
+      get :index, {}, session_for(user)
+      assert_includes @response.body, "zzzzz-xvhdp-cr4runningcntnr"
+      if crunch2
+        assert_not_includes @response.body, "zzzzz-d1hrv-1yfj6xkidf2muk3"
+      else
+        assert_includes @response.body, "zzzzz-d1hrv-1yfj6xkidf2muk3"
+      end
+    end
+  end
+end
diff --git a/apps/workbench/test/unit/disabled_api_test.rb b/apps/workbench/test/unit/disabled_api_test.rb
new file mode 100644
index 0000000..468ab5f
--- /dev/null
+++ b/apps/workbench/test/unit/disabled_api_test.rb
@@ -0,0 +1,15 @@
+require 'test_helper'
+
+class DisabledApiTest < ActiveSupport::TestCase
+  test 'Job.creatable? reflects whether jobs.create API is enabled' do
+    use_token(:active) do
+      assert(Job.creatable?)
+    end
+    dd = ArvadosApiClient.new_or_current.discovery
+    dd[:resources][:jobs][:methods].delete(:create)
+    ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
+    use_token(:active) do
+      refute(Job.creatable?)
+    end
+  end
+end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list