logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

obfuscate_filename_spec.rb (702B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe ApplicationController, type: :controller do
  4. controller do
  5. include ObfuscateFilename
  6. obfuscate_filename :file
  7. def file
  8. render plain: params[:file]&.original_filename
  9. end
  10. end
  11. before do
  12. routes.draw { get 'file' => 'anonymous#file' }
  13. end
  14. it 'obfusticates filename if the given parameter is specified' do
  15. file = fixture_file_upload('files/imports.txt', 'text/plain')
  16. post 'file', params: { file: file }
  17. expect(response.body).to end_with '.txt'
  18. expect(response.body).not_to include 'imports'
  19. end
  20. it 'does nothing if the given parameter is not specified' do
  21. post 'file'
  22. end
  23. end