17119: bugfix: when "count: none" is specified, the group/contents
authorWard Vandewege <ward@curii.com>
Wed, 24 Mar 2021 21:32:02 +0000 (17:32 -0400)
committerWard Vandewege <ward@curii.com>
Wed, 24 Mar 2021 21:32:02 +0000 (17:32 -0400)
       endpoint should not return the items_available field.

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

apps/workbench/app/controllers/application_controller.rb
services/api/app/controllers/arvados/v1/groups_controller.rb
services/api/test/functional/arvados/v1/query_test.rb

index 04449d5f19519a5cbdec5c6e2e4b7899641996c9..04055f84852ed4628aaf5a9d32ea79d72c59907f 100644 (file)
@@ -239,7 +239,7 @@ class ApplicationController < ActionController::Base
     if objects.respond_to?(:result_offset) and
         objects.respond_to?(:result_limit)
       next_offset = objects.result_offset + objects.result_limit
-      if objects.respond_to?(:items_available) and (next_offset < objects.items_available)
+      if objects.respond_to?(:items_available) and (objects.items_available != nil) and (next_offset < objects.items_available)
         next_offset
       elsif @objects.results.size > 0 and (params[:count] == 'none' or
            (params[:controller] == 'search' and params[:action] == 'choose'))
index 6498b7a512cce5329a3967692e808e0b1e97b7ef..5388e8ffbb6552608ac461ccd51fdd8259769e6d 100644 (file)
@@ -127,9 +127,11 @@ class Arvados::V1::GroupsController < ApplicationController
       :self_link => "",
       :offset => @offset,
       :limit => @limit,
-      :items_available => @items_available,
       :items => @objects.as_api_response(nil)
     }
+    if params[:count] != 'none'
+      list[:items_available] = @items_available
+    end
     if @extra_included
       list[:included] = @extra_included.as_api_response(nil, {select: @select})
     end
index dfa3b7fe778f4c56c897fd4d60e9816e579751ae..9bba418578e89c6dd36009ba2e3278f700d33eb3 100644 (file)
@@ -80,6 +80,16 @@ class Arvados::V1::QueryTest < ActionController::TestCase
     refute(json_response.has_key?('items_available'))
   end
 
+  test 'do not count items_available if count=none for group contents endpoint' do
+    @controller = Arvados::V1::GroupsController.new
+    authorize_with :active
+    get :contents, params: {
+      count: 'none',
+    }
+    assert_response(:success)
+    refute(json_response.has_key?('items_available'))
+  end
+
   [{}, {count: nil}, {count: ''}, {count: 'exact'}].each do |params|
     test "count items_available if params=#{params.inspect}" do
       @controller = Arvados::V1::LinksController.new