X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/19ae770973482257117fe8ded5619c3018c4b60f..e2a4e065951ea459570ae75dbe2ed4fd4b6d4bd8:/services/api/test/integration/collections_api_test.rb diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb index 4251047cea..5f55f5eaec 100644 --- a/services/api/test/integration/collections_api_test.rb +++ b/services/api/test/integration/collections_api_test.rb @@ -21,7 +21,7 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest :filters => ['uuid', '=', 'ad02e37b6a7f45bbe2ead3c29a109b8a+54'].to_json }, auth(:active) assert_response 422 - assert_match /nvalid element.*not an array/, json_response['errors'].join(' ') + assert_match(/nvalid element.*not an array/, json_response['errors'].join(' ')) end test "get index with invalid filters (unsearchable column) responds 422" do @@ -30,7 +30,7 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest :filters => [['this_column_does_not_exist', '=', 'bogus']].to_json }, auth(:active) assert_response 422 - assert_match /nvalid attribute/, json_response['errors'].join(' ') + assert_match(/nvalid attribute/, json_response['errors'].join(' ')) end test "get index with invalid filters (invalid operator) responds 422" do @@ -39,7 +39,7 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest :filters => [['uuid', ':-(', 'displeased']].to_json }, auth(:active) assert_response 422 - assert_match /nvalid operator/, json_response['errors'].join(' ') + assert_match(/nvalid operator/, json_response['errors'].join(' ')) end test "get index with invalid filters (invalid operand type) responds 422" do @@ -48,7 +48,7 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest :filters => [['uuid', '=', {foo: 'bar'}]].to_json }, auth(:active) assert_response 422 - assert_match /nvalid operand type/, json_response['errors'].join(' ') + assert_match(/nvalid operand type/, json_response['errors'].join(' ')) end test "get index with where= (empty string)" do @@ -57,6 +57,34 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest assert_equal "arvados#collectionList", json_response['kind'] end + test "get index with select= (valid attribute)" do + get "/arvados/v1/collections", { + :format => :json, + :select => ['portable_data_hash'].to_json + }, auth(:active) + assert_response :success + assert json_response['items'][0].keys.include?('portable_data_hash') + assert not(json_response['items'][0].keys.include?('uuid')) + end + + test "get index with select= (invalid attribute) responds 422" do + get "/arvados/v1/collections", { + :format => :json, + :select => ['bogus'].to_json + }, auth(:active) + assert_response 422 + assert_match(/Invalid attribute.*bogus/, json_response['errors'].join(' ')) + end + + test "get index with select= (invalid attribute type) responds 422" do + get "/arvados/v1/collections", { + :format => :json, + :select => [['bogus']].to_json + }, auth(:active) + assert_response 422 + assert_match(/Invalid attribute.*bogus/, json_response['errors'].join(' ')) + end + test "controller 404 response is json" do get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, auth(:active) assert_response 404 @@ -215,8 +243,6 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest assert_response :success assert_equal true, json_response['manifest_text'].include?('file4_in_subdir4.txt') - created = json_response - # search using the filename search_using_full_text_search 'subdir2', 0 search_using_full_text_search 'subdir2:*', 1