闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
702 B

  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