From: radhika Date: Tue, 6 Jun 2017 17:06:19 +0000 (-0400) Subject: 11652: use "recursive=true" in workbench search requests X-Git-Tag: 1.1.0~210^2~2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/f1aed11fd3a5e204a2cf2e4fc5f099179e877eb6 11652: use "recursive=true" in workbench search requests --- diff --git a/apps/workbench/app/controllers/search_controller.rb b/apps/workbench/app/controllers/search_controller.rb index 2511ab0818..3fa78365b9 100644 --- a/apps/workbench/app/controllers/search_controller.rb +++ b/apps/workbench/app/controllers/search_controller.rb @@ -15,6 +15,7 @@ class SearchController < ApplicationController end @objects = search_what.contents(limit: @limit, offset: @offset, + recursive: true, count: 'none', last_object_class: params["last_object_class"], filters: @filters) @@ -24,6 +25,7 @@ class SearchController < ApplicationController def next_page_href with_params={} super with_params.merge(last_object_class: @objects.last.class.to_s, project_uuid: params[:project_uuid], + recursive: true, count: 'none', filters: @filters.to_json) end diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb index f06193c3ec..58e3fb7a5c 100644 --- a/apps/workbench/app/models/arvados_base.rb +++ b/apps/workbench/app/models/arvados_base.rb @@ -156,6 +156,10 @@ class ArvadosBase < ActiveRecord::Base ArvadosResourceList.new(self).include_trash(*args) end + def self.recursive(*args) + ArvadosResourceList.new(self).recursive(*args) + end + def self.eager(*args) ArvadosResourceList.new(self).eager(*args) end diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb index 8ae48d8244..dea2f30d1d 100644 --- a/apps/workbench/app/models/arvados_resource_list.rb +++ b/apps/workbench/app/models/arvados_resource_list.rb @@ -26,6 +26,11 @@ class ArvadosResourceList self end + def recursive(option=nil) + @recursive = option + self + end + def limit(max_results) if not max_results.nil? and not max_results.is_a? Integer raise ArgumentError("argument to limit() must be an Integer or nil") diff --git a/apps/workbench/test/controllers/search_controller_test.rb b/apps/workbench/test/controllers/search_controller_test.rb index a09d966a18..2156c70160 100644 --- a/apps/workbench/test/controllers/search_controller_test.rb +++ b/apps/workbench/test/controllers/search_controller_test.rb @@ -39,4 +39,27 @@ class SearchControllerTest < ActionController::TestCase assert_empty(json_response['content'], 'search results for empty project should be empty') end + + test 'search results for aproject and verify recursive contents' do + xhr :get, :choose, { + format: :json, + partial: true, + project_uuid: api_fixture('groups')['aproject']['uuid'], + }, session_for(:active) + assert_response :success + assert_not_empty(json_response['content'], + 'search results for empty project should be empty') + items = [] + json_response['content'].scan /]+>/ do |div_tag| + div_tag.scan(/\ data-object-uuid=\"(.*?)\"/).each do |uuid,| + items << uuid + end + end + + assert_includes(items, api_fixture('collections')['collection_to_move_around_in_aproject']['uuid']) + assert_includes(items, api_fixture('groups')['asubproject']['uuid']) + assert_includes(items, api_fixture('collections')['baz_collection_name_in_asubproject']['uuid']) + assert_includes(items, + api_fixture('groups')['subproject_in_asubproject_with_same_name_as_one_in_active_user_home']['uuid']) + end end