[ARVADOS] created: d7c2ff977813e095b3dfcba82f534f6b5236b596
Git user
git at public.curoverse.com
Wed Nov 9 18:53:32 EST 2016
at d7c2ff977813e095b3dfcba82f534f6b5236b596 (commit)
commit d7c2ff977813e095b3dfcba82f534f6b5236b596
Author: radhika <radhika at curoverse.com>
Date: Wed Nov 9 18:53:07 2016 -0500
10310: remove unused helper method.
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 6923d52..6353d82 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -217,7 +217,7 @@ class ApplicationController < ActionController::Base
def ensure_arvados_api_exists
ctrl = params['controller'].to_sym
if [:jobs, :job_tasks, :pipeline_instances, :pipeline_templates].include?(ctrl)
- if !ctrl.to_s.classify.constantize.api_exists?(params['action'].to_sym)
+ if model_class < ArvadosBase && !model_class.api_exists?(params['action'].to_sym)
@errors = ["#{params['action']} method is not supported for #{ctrl}"]
return render_error(status: 404)
end
@@ -229,15 +229,6 @@ class ApplicationController < ActionController::Base
render_index
end
- helper_method :arvados_api_exists
- def arvados_api_exists ctrl, method
- if [:jobs, :job_tasks, :pipeline_instances, :pipeline_templates].include?(ctrl)
- ctrl.to_s.classify.constantize.api_exists?(method)
- else
- true
- end
- end
-
helper_method :next_page_offset
def next_page_offset objects=nil
if !objects
commit 05b55d204d19171589ef641edae3225a8a52f617
Author: radhika <radhika at curoverse.com>
Date: Wed Nov 9 18:38:07 2016 -0500
10310: Update most api_exists checks to use method from ArvadosBase
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index ee3d676..6923d52 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -215,10 +215,12 @@ class ApplicationController < ActionController::Base
end
def ensure_arvados_api_exists
- exists = arvados_api_exists params['controller'].to_sym, params['action'].to_sym
- if !exists
- @errors = ["#{params['action']} method is not supported for #{params['controller']}"]
- return render_error(status: 404)
+ ctrl = params['controller'].to_sym
+ if [:jobs, :job_tasks, :pipeline_instances, :pipeline_templates].include?(ctrl)
+ if !ctrl.to_s.classify.constantize.api_exists?(params['action'].to_sym)
+ @errors = ["#{params['action']} method is not supported for #{ctrl}"]
+ return render_error(status: 404)
+ end
end
end
@@ -879,7 +881,7 @@ class ApplicationController < ActionController::Base
lim = 12 if lim.nil?
procs = {}
- if arvados_api_exists :pipeline_instances, :index
+ if PipelineInstance.api_exists?(:index)
cols = %w(uuid owner_uuid created_at modified_at pipeline_template_uuid name state started_at finished_at)
pipelines = PipelineInstance.select(cols).limit(lim).order(["created_at desc"])
pipelines.results.each { |pi| procs[pi] = pi.created_at }
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index ebcc392..46dcab6 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -239,7 +239,7 @@ class CollectionsController < ApplicationController
render 'hash_matches'
return
else
- if arvados_api_exists :jobs, :index
+ if Job.api_exists?(:index)
jobs_with = lambda do |conds|
Job.limit(RELATION_LIMIT).where(conds)
.results.sort_by { |j| j.finished_at || j.created_at }
diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index 16ad811..0a2044a 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -55,13 +55,13 @@ class ProjectsController < ApplicationController
pane_list = []
procs = ["arvados#containerRequest"]
- if arvados_api_exists(:pipeline_instances, :index)
+ if PipelineInstance.api_exists?(:index)
procs << "arvados#pipelineInstance"
end
workflows = ["arvados#workflow"]
workflows_pane_name = 'Workflows'
- if arvados_api_exists(:pipeline_templates, :index)
+ if PipelineTemplate.api_exists?(:index)
workflows << "arvados#pipelineTemplate"
workflows_pane_name = 'Pipeline_templates'
end
@@ -226,7 +226,9 @@ class ProjectsController < ApplicationController
@name_link_for = {}
kind_filters.each do |attr,op,val|
(val.is_a?(Array) ? val : [val]).each do |type|
- next if(!arvados_api_exists(type.split('#')[-1].underscore.pluralize.to_sym, :index))
+ klass = type.split('#')[-1]
+ klass[0] = klass[0].capitalize
+ next if(!Object.const_get(klass).api_exists?(:index))
filters = @filters - kind_filters + [['uuid', 'is_a', type]]
if type == 'arvados#containerRequest'
diff --git a/apps/workbench/app/controllers/work_unit_templates_controller.rb b/apps/workbench/app/controllers/work_unit_templates_controller.rb
index 9926d5c..fe53ac4 100644
--- a/apps/workbench/app/controllers/work_unit_templates_controller.rb
+++ b/apps/workbench/app/controllers/work_unit_templates_controller.rb
@@ -6,7 +6,7 @@ class WorkUnitTemplatesController < ApplicationController
@filters = @filters || []
# get next page of pipeline_templates
- if arvados_api_exists :pipeline_templates, :index
+ if PipelineTemplate.api_exists?(:index)
filters = @filters + [["uuid", "is_a", ["arvados#pipelineTemplate"]]]
pipelines = PipelineTemplate.limit(@limit).order(["created_at desc"]).filter(filters)
end
diff --git a/apps/workbench/app/controllers/work_units_controller.rb b/apps/workbench/app/controllers/work_units_controller.rb
index d94dcda..3b611aa 100644
--- a/apps/workbench/app/controllers/work_units_controller.rb
+++ b/apps/workbench/app/controllers/work_units_controller.rb
@@ -14,13 +14,13 @@ class WorkUnitsController < ApplicationController
@filters = @filters || []
# get next page of pipeline_instances
- if arvados_api_exists :pipeline_instances, :index
+ if PipelineInstance.api_exists?(:index)
filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]]
pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters)
end
# get next page of jobs
- if arvados_api_exists :jobs, :index
+ if Job.api_exists?(:index)
filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
end
diff --git a/apps/workbench/test/controllers/disabled_api_test.rb b/apps/workbench/test/controllers/disabled_api_test.rb
index 7aa87f0..1b59088 100644
--- a/apps/workbench/test/controllers/disabled_api_test.rb
+++ b/apps/workbench/test/controllers/disabled_api_test.rb
@@ -2,27 +2,16 @@ 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
+ test "dashboard recent processes when pipeline_instance index API is disabled" do
+ @controller = ProjectsController.new
- if crunch2
- dd = ArvadosApiClient.new_or_current.discovery.deep_dup
- dd[:resources][:pipeline_instances][:methods].delete(:index)
- ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
- end
+ dd = ArvadosApiClient.new_or_current.discovery.deep_dup
+ dd[:resources][:pipeline_instances][:methods].delete(:index)
+ ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
- 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
+ get :index, {}, session_for(:active)
+ assert_includes @response.body, "zzzzz-xvhdp-cr4runningcntnr" # expect crs
+ assert_not_includes @response.body, "zzzzz-d1hrv-" # expect no pipelines
end
[
@@ -31,7 +20,7 @@ class DisabledApiTest < ActionController::TestCase
[:pipeline_instances, PipelineInstancesController.new],
[:pipeline_templates, PipelineTemplatesController.new],
].each do |ctrl_name, ctrl|
- test "#{ctrl_name} index page with crunch2" do
+ test "#{ctrl_name} index page when API is disabled" do
@controller = ctrl
dd = ArvadosApiClient.new_or_current.discovery.deep_dup
@@ -39,7 +28,7 @@ class DisabledApiTest < ActionController::TestCase
ArvadosApiClient.any_instance.stubs(:discovery).returns(dd)
get :index, {}, session_for(:active)
- assert_includes @response.body, "index method is not supported for #{ctrl_name.to_s}"
+ assert_response 404
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list