From 7a471e44cd1344fb6b08a38b6c78db7df8293f4d Mon Sep 17 00:00:00 2001 From: Alex Boyd Date: Thu, 7 Apr 2016 15:08:33 -0600 Subject: [PATCH] Always download files when downloading from the preview page Fixes CNVS-28388 Test plan: - Set up Canvadocs - Upload a file whose name ends with .txt to a course's files - Make a wiki page - Include a link to the file in the page - View the page - Click on the link - On the page you're taken to, click the "Download ..." link at the top - Verify the file gets downloaded instead of simply opened in a new tab Change-Id: Ib357f7edcc70a320f66707091209e43defbcd8c7 Reviewed-on: https://gerrit.instructure.com/76593 Tested-by: Jenkins Reviewed-by: Steven Burnett QA-Review: Deepeeca Soundarrajan Product-Review: Alex Boyd --- app/views/files/show.html.erb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/views/files/show.html.erb b/app/views/files/show.html.erb index 32e74aa720e..f2f6d29b6a5 100644 --- a/app/views/files/show.html.erb +++ b/app/views/files/show.html.erb @@ -2,7 +2,7 @@ <%= join_title @attachment.display_name, @context.name %> <% end %> <% add_crumb @attachment.display_name, context_url(@context, :context_file_url, @attachment) %> -<% download_url = context_url(@context, :context_file_download_url, @attachment.id) %> +<% download_url = context_url(@context, :context_file_download_url, @attachment.id, download_frd: 1) %> <% js_bundle 'module_sequence_footer' %> <% if !can_do(@attachment.context, @current_user, :manage_files) && (locked = @attachment.locked_for?(@current_user)) %>
@@ -13,6 +13,12 @@ <% end %>
<% else %> +

<%= @attachment.display_name %>

+
+ + <%= link_to "Download #{@attachment.display_name}", download_url %> + (<%= @attachment.readable_size %>) +
<% if @attachment.content_type == "application/x-shockwave-flash" %> @@ -29,26 +35,16 @@ - Download <%= @attachment.display_name %> <% elsif @attachment.inline_content? && !@attachment.canvadocable? %> <% js_bundle :file_inline %> <% elsif @attachment.content_type && @attachment.content_type.match(/\Aimage\//) %> -

<%= @attachment.display_name %>

<%= link_to(image_tag(download_url, :alt => @attachment.display_name), download_url) %> <% elsif @attachment.content_type && @attachment.content_type.match(/\Avideo\/|audio\//) %> <% js_bundle :file_preview %> -

<%= @attachment.display_name %>

>
- - <%= link_to "Download #{@attachment.display_name}", download_url %> - (<%= @attachment.readable_size %>) <% else %> <% js_bundle :file_show %> -

<%= @attachment.display_name %>

- - <%= link_to "Download #{@attachment.display_name}", download_url %> - (<%= @attachment.readable_size %>)
>
<% end %> <% end %>