Use an env var for Carrierwave's cache_dir
This commit is contained in:
parent
e93f57763e
commit
b2dc502ed5
4 changed files with 7 additions and 16 deletions
|
@ -1,9 +1,5 @@
|
||||||
class BaseUploader < CarrierWave::Uploader::Base
|
class BaseUploader < CarrierWave::Uploader::Base
|
||||||
def cache_dir
|
def cache_dir
|
||||||
if Rails.env.production?
|
Rails.application.secrets.carrierwave[:cache_dir]
|
||||||
'/tmp/tps-cache'
|
|
||||||
else
|
|
||||||
'/tmp/tps-dev-cache'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,7 @@ FOG_OPENSTACK_AUTH_URL=""
|
||||||
FOG_OPENSTACK_REGION=""
|
FOG_OPENSTACK_REGION=""
|
||||||
FOG_DIRECTORY=""
|
FOG_DIRECTORY=""
|
||||||
FOG_ENABLED=""
|
FOG_ENABLED=""
|
||||||
|
CARRIERWAVE_CACHE_DIR="/tmp/tps-local-cache"
|
||||||
|
|
||||||
CLEVER_CLOUD_ACCESS_KEY_ID=""
|
CLEVER_CLOUD_ACCESS_KEY_ID=""
|
||||||
CLEVER_CLOUD_SECRET_ACCESS_KEY=""
|
CLEVER_CLOUD_SECRET_ACCESS_KEY=""
|
||||||
|
|
|
@ -40,6 +40,8 @@ defaults: &defaults
|
||||||
openstack_auth_url: <%= ENV['FOG_OPENSTACK_AUTH_URL'] %>
|
openstack_auth_url: <%= ENV['FOG_OPENSTACK_AUTH_URL'] %>
|
||||||
openstack_region: <%= ENV['FOG_OPENSTACK_REGION'] %>
|
openstack_region: <%= ENV['FOG_OPENSTACK_REGION'] %>
|
||||||
directory: <%= ENV['FOG_DIRECTORY'] %>
|
directory: <%= ENV['FOG_DIRECTORY'] %>
|
||||||
|
carrierwave:
|
||||||
|
cache_dir: <%= ENV['CARRIERWAVE_CACHE_DIR'] %>
|
||||||
mailtrap:
|
mailtrap:
|
||||||
username: <%= ENV['MAILTRAP_USERNAME'] %>
|
username: <%= ENV['MAILTRAP_USERNAME'] %>
|
||||||
password: <%= ENV['MAILTRAP_PASSWORD'] %>
|
password: <%= ENV['MAILTRAP_PASSWORD'] %>
|
||||||
|
@ -60,6 +62,8 @@ test:
|
||||||
key: api_entreprise_test_key
|
key: api_entreprise_test_key
|
||||||
fog:
|
fog:
|
||||||
directory: tps_dev
|
directory: tps_dev
|
||||||
|
carrierwave:
|
||||||
|
cache_dir: /tmp/tps-test-cache
|
||||||
pipedrive:
|
pipedrive:
|
||||||
key: pipedrive_test_key
|
key: pipedrive_test_key
|
||||||
france_connect_particulier:
|
france_connect_particulier:
|
||||||
|
|
|
@ -6,16 +6,6 @@ describe BaseUploader do
|
||||||
describe '#cache_dir' do
|
describe '#cache_dir' do
|
||||||
subject { uploader.cache_dir }
|
subject { uploader.cache_dir }
|
||||||
|
|
||||||
context 'when rails env is not production' do
|
it { is_expected.to eq '/tmp/tps-test-cache' }
|
||||||
it { is_expected.to eq '/tmp/tps-dev-cache' }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when rails env is not production' do
|
|
||||||
before do
|
|
||||||
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to eq '/tmp/tps-cache' }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue