diff --git a/app/uploaders/remote_downloader.rb b/app/uploaders/remote_downloader.rb index 1e6dbcd66..44a6e6eec 100644 --- a/app/uploaders/remote_downloader.rb +++ b/app/uploaders/remote_downloader.rb @@ -4,7 +4,9 @@ class RemoteDownloader end def url - @url ||= File.join(base_url, CarrierWave::Uploader::Base.fog_directory, @filename) + if @filename.present? + @url ||= File.join(base_url, CarrierWave::Uploader::Base.fog_directory, @filename) + end end protected diff --git a/spec/uploaders/remote_downloader_spec.rb b/spec/uploaders/remote_downloader_spec.rb index 1bcd41ad9..e49e52ce8 100644 --- a/spec/uploaders/remote_downloader_spec.rb +++ b/spec/uploaders/remote_downloader_spec.rb @@ -7,5 +7,11 @@ describe RemoteDownloader do describe '#url' do it { expect(subject.url).to eq 'https://static.demarches-simplifiees.fr/tps_dev/file_name.pdf' } + + context 'no filename' do + let(:filename) { nil } + + it { expect(subject.url).to be_nil } + end end end