1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class Arvados::V1::QueryTest < ActionController::TestCase
8 test 'no fallback orders when order is unambiguous' do
9 @controller = Arvados::V1::LogsController.new
10 authorize_with :active
15 assert_response :success
16 assert_equal ['logs.id asc'], assigns(:objects).order_values
19 test 'fallback orders when order is ambiguous' do
20 @controller = Arvados::V1::LogsController.new
21 authorize_with :active
23 order: ['event_type asc'],
26 assert_response :success
27 assert_equal('logs.event_type asc, logs.modified_at desc, logs.uuid desc',
28 assigns(:objects).order_values.join(', '))
31 test 'skip fallback orders already given by client' do
32 @controller = Arvados::V1::LogsController.new
33 authorize_with :active
35 order: ['modified_at asc'],
38 assert_response :success
39 assert_equal('logs.modified_at asc, logs.uuid desc',
40 assigns(:objects).order_values.join(', '))
43 test 'eliminate superfluous orders' do
44 @controller = Arvados::V1::LogsController.new
45 authorize_with :active
47 order: ['logs.modified_at asc',
50 'logs.event_type asc'],
53 assert_response :success
54 assert_equal('logs.modified_at asc, logs.event_type desc, logs.uuid desc',
55 assigns(:objects).order_values.join(', '))
58 test 'eliminate orders after the first unique column' do
59 @controller = Arvados::V1::LogsController.new
60 authorize_with :active
62 order: ['event_type asc',
68 assert_response :success
69 assert_equal('logs.event_type asc, logs.id asc',
70 assigns(:objects).order_values.join(', '))
73 test 'do not count items_available if count=none' do
74 @controller = Arvados::V1::LinksController.new
75 authorize_with :active
79 assert_response(:success)
80 refute(json_response.has_key?('items_available'))
83 test 'do not count items_available if count=none for group contents endpoint' do
84 @controller = Arvados::V1::GroupsController.new
85 authorize_with :active
86 get :contents, params: {
89 assert_response(:success)
90 refute(json_response.has_key?('items_available'))
93 [{}, {count: nil}, {count: ''}, {count: 'exact'}].each do |params|
94 test "count items_available if params=#{params.inspect}" do
95 @controller = Arvados::V1::LinksController.new
96 authorize_with :active
97 get :index, params: params
98 assert_response(:success)
99 assert_operator(json_response['items_available'], :>, 0)
103 test 'error if count=bogus' do
104 @controller = Arvados::V1::LinksController.new
105 authorize_with :active
106 get :index, params: {