Skip to content

Commit

Permalink
Merge pull request #4143 from sanger/y24-069-submission-filename-too-…
Browse files Browse the repository at this point in the history
…long-2

Y24-069-2 Only show a single barcode when one is entered
  • Loading branch information
StephenHulme authored Jun 18, 2024
2 parents 33e9f0c + 5998603 commit de9c5cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions app/controllers/bulk_submission_excel/downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ def submission_parameters
# Follows the format: first barcode_to_last barcode_date_sanger user ID
# e.g. "SQPP-1234_to_SQPP-5678_20240521_ec20.xlsx"
def build_filename(barcodes)
first_barcode = barcodes.first
last_barcode = barcodes.last
date = Time.current.utc.strftime('%Y%m%d')
username = current_user.login
barcode_part = barcodes.one? ? barcodes.first.to_s : "#{barcodes.first}_to_#{barcodes.last}"

"#{first_barcode}_to_#{last_barcode}_#{date}_#{username}.xlsx"
"#{barcode_part}_#{date}_#{username}.xlsx"
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
it 'generates an Excel file with the correct headers' do
post :create, params: valid_attributes
expect(response.headers['Content-Disposition']).to include(
"#{barcodes.first}_to_#{barcodes.first}_#{Time.current.utc.strftime('%Y%m%d')}_#{session[:user].login}.xlsx"
"#{barcodes.first}_#{Time.current.utc.strftime('%Y%m%d')}_#{session[:user].login}.xlsx"
)
end
end
Expand Down

0 comments on commit de9c5cf

Please sign in to comment.