diff --git a/app/helpers/upload_helper.rb b/app/helpers/upload_helper.rb index a6aa51de6b..c1598b0d0c 100644 --- a/app/helpers/upload_helper.rb +++ b/app/helpers/upload_helper.rb @@ -4,7 +4,7 @@ module UploadHelper def upload_link_to(upload) href = govuk_link_to( - "#{upload.name} (opens in a new tab)", + "#{upload.filename} (opens in a new tab)", upload_path(upload), target: :_blank, rel: :noopener, diff --git a/app/models/upload.rb b/app/models/upload.rb index ba6ab75225..f8f21bb277 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -38,12 +38,6 @@ def original? !translation? end - def name - return "File upload error" if scan_result_suspect? - - attachment.filename.to_s - end - def url attachment.url(expires_in: 5.minutes) end diff --git a/app/views/assessor_interface/consent_requests/edit_verify.html.erb b/app/views/assessor_interface/consent_requests/edit_verify.html.erb index f073cf7811..17047bb28e 100644 --- a/app/views/assessor_interface/consent_requests/edit_verify.html.erb +++ b/app/views/assessor_interface/consent_requests/edit_verify.html.erb @@ -18,7 +18,7 @@

Returned file

<% if @consent_request.received? %> -

<%= upload.name %>

+

<%= upload.filename %>

<% if upload.is_pdf? %> diff --git a/app/views/teacher_interface/documents/edit_uploads.html.erb b/app/views/teacher_interface/documents/edit_uploads.html.erb index 81da322e31..9abce4050f 100644 --- a/app/views/teacher_interface/documents/edit_uploads.html.erb +++ b/app/views/teacher_interface/documents/edit_uploads.html.erb @@ -31,13 +31,13 @@ row.with_action( text: "Delete", href: delete_teacher_interface_application_form_document_upload_path(@document, upload), - visually_hidden_text: upload.attachment.filename + visually_hidden_text: upload.filename ) else row.with_action( text: "Change", href: new_teacher_interface_application_form_document_upload_path(@document), - visually_hidden_text: upload.attachment.filename + visually_hidden_text: upload.filename ) end end diff --git a/app/views/teacher_interface/uploads/delete.html.erb b/app/views/teacher_interface/uploads/delete.html.erb index eba85c2ce9..c366612943 100644 --- a/app/views/teacher_interface/uploads/delete.html.erb +++ b/app/views/teacher_interface/uploads/delete.html.erb @@ -1,4 +1,4 @@ -<% content_for :page_title, title_with_error_prefix("Delete #{@upload.attachment.filename}", error: @form.errors.any?) %> +<% content_for :page_title, title_with_error_prefix("Delete #{@upload.filename}", error: @form.errors.any?) %> <% content_for :back_link_url, back_history_path(default: edit_teacher_interface_application_form_document_path(@document)) %> <%= form_with model: @form, url: [:teacher_interface, :application_form, @document, @upload], method: :delete do |f| %> @@ -9,7 +9,7 @@ :id, :name, inline: true, - legend: { text: "Are you sure you want to delete #{@upload.attachment.filename}?", size: "l", tag: "h1" } %> + legend: { text: "Are you sure you want to delete #{@upload.filename}?", size: "l", tag: "h1" } %> <%= f.govuk_submit %> <% end %> diff --git a/spec/factories/documents.rb b/spec/factories/documents.rb index 8715e2532d..8c3b32f23b 100644 --- a/spec/factories/documents.rb +++ b/spec/factories/documents.rb @@ -26,13 +26,13 @@ trait :with_upload do after(:create) do |document, _evaluator| - create(:upload, :clean, document:) + create(:upload, :clean, document:, filename: "upload.pdf") end end trait :with_translation do after(:create) do |document, _evaluator| - create(:upload, :translation, :clean, document:) + create(:upload, :translation, :clean, document:, filename: "upload.pdf") end end diff --git a/spec/helpers/upload_helper_spec.rb b/spec/helpers/upload_helper_spec.rb index a4f16a74fb..9dbca92466 100644 --- a/spec/helpers/upload_helper_spec.rb +++ b/spec/helpers/upload_helper_spec.rb @@ -9,7 +9,7 @@ it "returns a link to the upload" do expect(upload_link_to).to have_link( - "#{upload.name} (opens in a new tab)", + "#{upload.filename} (opens in a new tab)", href: "/teacher/application/documents/#{upload.document.id}/uploads/#{upload.id}", ) @@ -24,7 +24,7 @@ it "returns a link to the upload" do expect(upload_link_to).to have_link( - "#{upload.name} (opens in a new tab)", + "#{upload.filename} (opens in a new tab)", href: "/assessor/application/documents/#{upload.document.id}/uploads/#{upload.id}", ) @@ -39,7 +39,7 @@ it "returns text for a pending scan" do expect(upload_link_to).to have_link( - upload.name, + upload.filename, href: "/teacher/application/documents/#{upload.document.id}/uploads/#{upload.id}", ) diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index f1d067c4b9..5cb5ee688c 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -40,17 +40,6 @@ end end - describe "#name" do - subject(:name) { upload.name } - - it { is_expected.to eq("upload.pdf") } - - context "when a malware scan is suspect" do - before { upload.malware_scan_result = "suspect" } - it { is_expected.to eq("File upload error") } - end - end - describe "#url" do subject(:url) { upload.url } diff --git a/spec/system/teacher_interface/malware_scanning_spec.rb b/spec/system/teacher_interface/malware_scanning_spec.rb index f13d14310c..ea39e9889f 100644 --- a/spec/system/teacher_interface/malware_scanning_spec.rb +++ b/spec/system/teacher_interface/malware_scanning_spec.rb @@ -59,10 +59,10 @@ def then_i_see_the_check_your_uploaded_files_page def and_the_uploaded_files_have_been_marked_as_malware expect(teacher_check_uploaded_files_page.files).to have_content( - "File 1\tFile upload error (opens in a new tab)\nThere’s a problem with this file", + "File 1\tupload.pdf (opens in a new tab)\nThere’s a problem with this file", ) expect(teacher_check_uploaded_files_page.files).to have_content( - "File 2\tFile upload error (opens in a new tab)\nThere’s a problem with this file", + "File 2\tupload.pdf (opens in a new tab)\nThere’s a problem with this file", ) end @@ -76,7 +76,7 @@ def and_the_uploaded_files_have_been_removed end def when_i_click_on_a_file_marked_as_malware - first("a", text: "File upload error").click + first("a", text: "upload.pdf").click end def then_i_see_theres_a_problem_with_the_file