From 8ff45c79780af8256601423d596343a4a4603f88 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 31 Oct 2018 12:50:48 +0100 Subject: [PATCH] Fix commentaire file_url generator --- app/uploaders/remote_downloader.rb | 4 +++- spec/uploaders/remote_downloader_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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