X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5ea0a240eb08a4d43d5f7670a694f0158f0bac36..0e2a467a923bd490f3e1dc4d8c00a9e2f29e59d4:/services/api/test/integration/collections_api_test.rb?ds=sidebyside diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb index 78edbffa6f..86195fba75 100644 --- a/services/api/test/integration/collections_api_test.rb +++ b/services/api/test/integration/collections_api_test.rb @@ -281,18 +281,58 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest ["true", true], ["1", true] ].each do |param, truthiness| - test "include_trash=#{param} param encoding via query string should be interpreted as include_trash=#{truthiness}" do + test "include_trash=#{param.inspect} param JSON-encoded should be interpreted as include_trash=#{truthiness}" do expired_col = collections(:expired_collection) assert expired_col.is_trashed - params = { - :include_trash => param, - } - get "/arvados/v1/collections?#{params.to_query}", + # Try #index first + post "/arvados/v1/collections", + params: { + :_method => 'GET', + :include_trash => param, + :filters => [['uuid', '=', expired_col.uuid]].to_json + }, + headers: auth(:active) + assert_response :success + assert_not_nil json_response['items'] + assert_equal truthiness, json_response['items'].collect {|c| c['uuid']}.include?(expired_col.uuid) + # Try #show next + post "/arvados/v1/collections/#{expired_col.uuid}", + params: { + :_method => 'GET', + :include_trash => param, + }, headers: auth(:active) + if truthiness + assert_response :success + else + assert_response 404 + end + end + end + + [ + ["false", false], + ["0", false], + ["true", true], + ["1", true] + ].each do |param, truthiness| + test "include_trash=#{param.inspect} param encoding via query string should be interpreted as include_trash=#{truthiness}" do + expired_col = collections(:expired_collection) + assert expired_col.is_trashed + # Try #index first + get("/arvados/v1/collections?include_trash=#{param}&filters=#{[['uuid','=',expired_col.uuid]].to_json}", + headers: auth(:active)) assert_response :success assert_not_nil json_response['items'] - refute_empty json_response['items'] assert_equal truthiness, json_response['items'].collect {|c| c['uuid']}.include?(expired_col.uuid) + # Try #show next + get("/arvados/v1/collections/#{expired_col.uuid}?include_trash=#{param}", + headers: auth(:active)) + if truthiness + assert_response :success + else + assert_response 404 + end end end @@ -302,21 +342,34 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest ["true", true], ["1", true] ].each do |param, truthiness| - test "include_trash=#{param} form-encoded param should be interpreted as include_trash=#{truthiness}" do + test "include_trash=#{param.inspect} form-encoded param should be interpreted as include_trash=#{truthiness}" do expired_col = collections(:expired_collection) assert expired_col.is_trashed params = [ + ['_method', 'GET'], ['include_trash', param], + ['filters', [['uuid','=',expired_col.uuid]].to_json], ] - get "/arvados/v1/collections", + # Try #index first + post "/arvados/v1/collections", params: URI.encode_www_form(params), headers: { "Content-type" => "application/x-www-form-urlencoded" }.update(auth(:active)) assert_response :success assert_not_nil json_response['items'] - refute_empty json_response['items'] assert_equal truthiness, json_response['items'].collect {|c| c['uuid']}.include?(expired_col.uuid) + # Try #show next + post "/arvados/v1/collections/#{expired_col.uuid}", + params: URI.encode_www_form([['_method', 'GET'],['include_trash', param]]), + headers: { + "Content-type" => "application/x-www-form-urlencoded" + }.update(auth(:active)) + if truthiness + assert_response :success + else + assert_response 404 + end end end