2764: Introduce show_file_links route.
authorBrett Smith <brett@curoverse.com>
Thu, 15 May 2014 19:54:32 +0000 (15:54 -0400)
committerBrett Smith <brett@curoverse.com>
Wed, 21 May 2014 19:16:35 +0000 (15:16 -0400)
Right now this just takes advantage of the provided reader token, but
we're going to extend it to provide a wget-friendly view.

apps/workbench/app/controllers/collections_controller.rb
apps/workbench/config/routes.rb
apps/workbench/test/functional/collections_controller_test.rb

index 43ff754da8ab07c5db0b5b653ad337f5337b7cd1..7a8888e1d230885b7cfd78b430eae4ce74582381 100644 (file)
@@ -1,7 +1,8 @@
 class CollectionsController < ApplicationController
-  skip_around_filter :thread_with_mandatory_api_token, only: [:show_file]
-  skip_before_filter :find_object_by_uuid, only: [:provenance, :show_file]
-  skip_before_filter :check_user_agreements, only: [:show_file]
+  skip_around_filter(:thread_with_mandatory_api_token,
+                     only: [:show_file, :show_file_links])
+  skip_before_filter(:find_object_by_uuid,
+                     only: [:provenance, :show_file, :show_file_links])
 
   RELATION_LIMIT = 5
 
@@ -89,6 +90,13 @@ class CollectionsController < ApplicationController
     @request_url = request.url
   end
 
+  def show_file_links
+    Thread.current[:reader_tokens] = [params[:reader_token]]
+    find_object_by_uuid
+    show
+    render 'show'
+  end
+
   def show_file
     # We pipe from arv-get to send the file to the user.  Before we start it,
     # we ask the API server if the file actually exists.  This serves two
index 30ac241333a0dcf6dbb90cd6f09fe1b42772dc58..c12cc989d71cd182ac16003909c67e21cecfa04d 100644 (file)
@@ -44,9 +44,10 @@ ArvadosWorkbench::Application.routes.draw do
   resources :collections do
     post 'set_persistent', on: :member
   end
-  get '/collections/:uuid/*file' => 'collections#show_file', :format => false
   get('/collections/download/:uuid/:reader_token/*file' => 'collections#show_file',
       format: false)
+  get '/collections/download/:uuid/:reader_token' => 'collections#show_file_links'
+  get '/collections/:uuid/*file' => 'collections#show_file', :format => false
   resources :folders do
     match 'remove/:item_uuid', on: :member, via: :delete, action: :remove_item
   end
index b31e718e4d058fcd8fbd357122e8b90586b0118e..19d08d73b35896b8116eb42c7d8dfecf42294177 100644 (file)
@@ -89,11 +89,10 @@ class CollectionsControllerTest < ActionController::TestCase
   end
 
   test "viewing collection files with a reader token" do
-    skip  # Need a new route+view for this.
     params = collection_params(:foo_file)
     params[:reader_token] =
       api_fixture('api_client_authorizations')['active']['api_token']
-    get(:show, params)
+    get(:show_file_links, params)
     assert_response :success
     assert_equal([['.', 'foo', 3]], assigns(:object).files)
     assert_no_session