--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>
+ <% if content_for? :page_title %>
+ <%= yield :page_title %> / <%= Rails.configuration.site_name %>
+ <% else %>
+ <%= Rails.configuration.site_name %>
+ <% end %>
+ </title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+ <meta name="robots" content="NOINDEX">
+</head>
+<body>
+<% content_for :page_title do %>
+ <%= (@object.respond_to?(:properties) ? @object.properties[:page_title] : nil) ||
+ @object.friendly_link_name %>
+<% end %>
+
+<% if @object.andand.files.andand.any? %>
+ <% link_opts = {controller: 'collections', action: 'show_file',
+ uuid: @object.uuid, reader_token: params[:reader_token]} %>
+ <ul>
+ <% @object.files.map { |spec|
+ CollectionsHelper::file_path(spec)
+ }.each do |path| %>
+ <li><%= link_to(path, link_opts.merge(file: path)) %></li>
+ <% end %>
+ </ul>
+<% else %>
+ <p>No files in this collection.</p>
+<% end %>
+</body>
+</html>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<meta name="description" content="">
<meta name="author" content="">
+ <meta name="robots" content="NOINDEX, NOFOLLOW">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
require 'headless'
class CollectionsTest < ActionDispatch::IntegrationTest
-
def change_persist oldstate, newstate
find "div[data-persistent-state='#{oldstate}']"
page.assert_no_selector "div[data-persistent-state='#{newstate}']"
# isn't only showing up in an error message.
assert(page.has_link?('foo'), "Collection page did not include file link")
end
+
+ test "can download an entire collection with a reader token" do
+ uuid = api_fixture('collections')['foo_file']['uuid']
+ token = api_fixture('api_client_authorizations')['active_all_collections']['api_token']
+ url_head = "/collections/download/#{uuid}/#{token}/"
+ visit url_head
+ # It seems that Capybara can't inspect tags outside the body, so this is
+ # a very blunt approach.
+ assert_no_match(/<\s*meta[^>]+\bnofollow\b/i, page.html,
+ "wget prohibited from recursing the collection page")
+ # TODO: When we can test against a Keep server, actually follow links
+ # and check their contents, rather than testing the href directly
+ # (this is too closely tied to implementation details).
+ hrefs = page.all('a').map do |anchor|
+ link = anchor[:href] || ''
+ if link.start_with? url_head
+ link[url_head.size .. -1]
+ elsif link.start_with? '/'
+ nil
+ else
+ link
+ end
+ end
+ assert_equal(['foo'], hrefs.compact.sort,
+ "download page did provide strictly file links")
+ end
end