3 class Arvados::V1::QueryTest < ActionController::TestCase
4 test 'no fallback orders when order is unambiguous' do
5 @controller = Arvados::V1::LogsController.new
11 assert_response :success
12 assert_equal ['logs.id asc'], assigns(:objects).order_values
15 test 'fallback orders when order is ambiguous' do
16 @controller = Arvados::V1::LogsController.new
17 authorize_with :active
19 order: ['event_type asc'],
22 assert_response :success
23 assert_equal('logs.event_type asc, logs.modified_at desc, logs.uuid',
24 assigns(:objects).order_values.join(', '))
27 test 'skip fallback orders already given by client' do
28 @controller = Arvados::V1::LogsController.new
29 authorize_with :active
31 order: ['modified_at asc'],
34 assert_response :success
35 assert_equal('logs.modified_at asc, logs.uuid',
36 assigns(:objects).order_values.join(', '))
39 test 'eliminate superfluous orders' do
40 @controller = Arvados::V1::LogsController.new
41 authorize_with :active
43 order: ['logs.modified_at asc',
46 'logs.event_type asc'],
49 assert_response :success
50 assert_equal('logs.modified_at asc, logs.event_type desc, logs.uuid',
51 assigns(:objects).order_values.join(', '))
54 test 'eliminate orders after the first unique column' do
55 @controller = Arvados::V1::LogsController.new
56 authorize_with :active
58 order: ['event_type asc',
64 assert_response :success
65 assert_equal('logs.event_type asc, logs.id asc',
66 assigns(:objects).order_values.join(', '))
69 test 'do not count items_available if count=none' do
70 @controller = Arvados::V1::LinksController.new
71 authorize_with :active
75 assert_response(:success)
76 refute(json_response.has_key?('items_available'))
79 [{}, {count: nil}, {count: ''}, {count: 'exact'}].each do |params|
80 test "count items_available if params=#{params.inspect}" do
81 @controller = Arvados::V1::LinksController.new
82 authorize_with :active
84 assert_response(:success)
85 assert_operator(json_response['items_available'], :>, 0)
89 test 'error if count=bogus' do
90 @controller = Arvados::V1::LinksController.new
91 authorize_with :active