From 701074a294c18ad56b7f17cfc488a2cbc25816d5 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 14 Feb 2014 11:26:44 -0800 Subject: [PATCH] Provide manifest_text in collections.get API response. refs #2070 --- .../arvados/v1/collections_controller.rb | 4 ++++ services/api/app/models/collection.rb | 4 ++++ .../arvados/v1/collections_controller_test.rb | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb index dc95ea064d..c0cd419819 100644 --- a/services/api/app/controllers/arvados/v1/collections_controller.rb +++ b/services/api/app/controllers/arvados/v1/collections_controller.rb @@ -51,6 +51,10 @@ class Arvados::V1::CollectionsController < ApplicationController show end + def show + render json: @object.as_api_response(:with_data) + end + def collection_uuid(uuid) m = /([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?/.match(uuid) if m diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index ef8a909a98..f6c8b26598 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -8,6 +8,10 @@ class Collection < ArvadosModel t.add :files end + api_accessible :with_data, extend: :user do |t| + t.add :manifest_text + end + def redundancy_status if redundancy_confirmed_as.nil? 'unconfirmed' diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb index bffb47a75c..0663eb94d5 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -11,14 +11,24 @@ class Arvados::V1::CollectionsControllerTest < ActionController::TestCase test "should create" do authorize_with :active + test_collection = { + manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n", + uuid: "d30fe8ae534397864cb96c544f4cf102" + } post :create, { - collection: { - manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n", - uuid: "d30fe8ae534397864cb96c544f4cf102" - } + collection: test_collection } assert_response :success assert_nil assigns(:objects) + + get :show, { + id: "d30fe8ae534397864cb96c544f4cf102" + } + assert_response :success + assert_not_nil assigns(:object) + resp = JSON.parse(@response.body) + assert_equal 'd30fe8ae534397864cb96c544f4cf102+47', resp['uuid'] + assert_equal test_collection[:manifest_text], resp['manifest_text'] end test "create with owner_uuid set to owned group" do -- 2.30.2