From: Tom Clegg Date: Thu, 8 Jun 2017 18:21:21 +0000 (-0400) Subject: 11837: Fix "include_trash" scope and test case. X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/eae753b5e9955b1c3e29782c983c25a3cb165781 11837: Fix "include_trash" scope and test case. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb index 73a7e09c5e..e3c10b78ee 100644 --- a/services/api/app/controllers/arvados/v1/collections_controller.rb +++ b/services/api/app/controllers/arvados/v1/collections_controller.rb @@ -13,7 +13,7 @@ class Arvados::V1::CollectionsController < ApplicationController def find_objects_for_index if params[:include_trash] || ['destroy', 'trash', 'untrash'].include?(action_name) - @objects = Collection.readable_by(*@read_users).unscoped + @objects = Collection.unscoped.readable_by(*@read_users) end super end diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index bb33c5595a..d1a0bc5794 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -250,7 +250,8 @@ class ArvadosModel < ActiveRecord::Base # Check if any of the users are admin. If so, we're done. if users_list.select { |u| u.is_admin }.any? - return self + # Return existing relation with no new filters. + return where({}) end # Collect the UUIDs of the authorized users. diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb index 055af9e67c..17af916b3d 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -1045,7 +1045,7 @@ EOS [:active, :admin].each do |user| test "get trashed collections as #{user}" do - authorize_with :active + authorize_with user get :index, { filters: [["is_trashed", "=", true]], include_trash: true,