From abc3a4f817d6ff53b992d1460a5f793f35e6549b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 15:54:24 +0200 Subject: [PATCH 01/15] Remove a now unused env var --- config/env.example | 1 - 1 file changed, 1 deletion(-) diff --git a/config/env.example b/config/env.example index 9d46cc0d7..e6814b693 100644 --- a/config/env.example +++ b/config/env.example @@ -9,6 +9,5 @@ FC_PARTICULIER_SECRET="" FC_PARTICULIER_BASE_URL="" API_ENTREPRISE_KEY="" -API_ENTREPRISE_BASE_URL="https://entreprise.api.gouv.fr/v2" PIPEDRIVE_KEY="" From 08df16c6f8e4543c28b2776a00cde4293b62c5c7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 15:54:32 +0200 Subject: [PATCH 02/15] Add missing env vars --- config/env.example | 50 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/config/env.example b/config/env.example index e6814b693..71e28a786 100644 --- a/config/env.example +++ b/config/env.example @@ -1,13 +1,59 @@ APP_NAME="tps_local" APP_HOST="localhost:3000" +SOURCE="tps_local" -GITHUB_CLIENT_ID="" -GITHUB_CLIENT_SECRET="" +SECRET_KEY_BASE="" +SIGNING_KEY="" + +DB_DATABASE="" +DB_HOST="" +DB_POOL="" +DB_USERNAME="" +DB_PASSWORD="" + +BASIC_AUTH_ENABLED="" +BASIC_AUTH_USERNAME="" +BASIC_AUTH_PASSWORD="" + +FOG_OPENSTACK_TENANT="" +FOG_OPENSTACK_API_KEY="" +FOG_OPENSTACK_USERNAME="" +FOG_OPENSTACK_AUTH_URL="" +FOG_OPENSTACK_REGION="" +FOG_DIRECTORY="" +FOG_ENABLED="" + +CLEVER_CLOUD_ACCESS_KEY_ID="" +CLEVER_CLOUD_SECRET_ACCESS_KEY="" +CLEVER_CLOUD_BUCKET="" FC_PARTICULIER_ID="" FC_PARTICULIER_SECRET="" FC_PARTICULIER_BASE_URL="" +GITHUB_CLIENT_ID="" +GITHUB_CLIENT_SECRET="" + +HELPSCOUT_MAILBOX_ID="" +HELPSCOUT_CLIENT_ID="" +HELPSCOUT_CLIENT_SECRET="" +HELPSCOUT_WEBHOOK_SECRET="" + +SENTRY_ENABLED="" +SENTRY_DSN_RAILS="" +SENTRY_DSN_JS="" + +MAILTRAP_ENABLED="disabled" +MAILTRAP_USERNAME="" +MAILTRAP_PASSWORD="" + +MAILJET_API_KEY="" +MAILJET_SECRET_KEY="" + API_ENTREPRISE_KEY="" PIPEDRIVE_KEY="" + +SKYLIGHT_AUTHENTICATION_KEY="" + +LOGRAGE_ENABLED="" From e4f4f5be8c44905173ea242ebfb3a7d0728346e3 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 15:54:49 +0200 Subject: [PATCH 03/15] Move some conf to env.example --- config/env.example | 4 ++-- config/secrets.yml | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/config/env.example b/config/env.example index 71e28a786..7fc55f8ad 100644 --- a/config/env.example +++ b/config/env.example @@ -2,8 +2,8 @@ APP_NAME="tps_local" APP_HOST="localhost:3000" SOURCE="tps_local" -SECRET_KEY_BASE="" -SIGNING_KEY="" +SECRET_KEY_BASE="05a2d479d8e412198dabd08ef0eee9d6e180f5cbb48661a35fd1cae287f0a93d40b5f1da08f06780d698bbd458a0ea97f730f83ee780de5d4e31f649a0130cf0" +SIGNING_KEY="aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017" DB_DATABASE="" DB_HOST="" diff --git a/config/secrets.yml b/config/secrets.yml index c2d61cef4..8b5d5db9f 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -52,8 +52,6 @@ defaults: &defaults development: <<: *defaults - secret_key_base: 05a2d479d8e412198dabd08ef0eee9d6e180f5cbb48661a35fd1cae287f0a93d40b5f1da08f06780d698bbd458a0ea97f730f83ee780de5d4e31f649a0130cf0 - signing_key: aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017 test: <<: *defaults From a23418f12b153b6675c212ccc0e071c416f3541d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 15:57:59 +0200 Subject: [PATCH 04/15] Move the local db conf to env.example --- config/database.yml | 8 ++++---- config/env.example | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/database.yml b/config/database.yml index cd1f7fcf8..1f4b1a8f2 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,10 +6,10 @@ default: &default development: <<: *default - database: tps_development - host: localhost - username: tps_development - password: tps_development + database: <%= ENV["DB_DATABASE"] %> + host: <%= ENV["DB_HOST"] %> + username: <%= ENV["DB_USERNAME"] %> + password: <%= ENV["DB_PASSWORD"] %> test: <<: *default diff --git a/config/env.example b/config/env.example index 7fc55f8ad..626b69355 100644 --- a/config/env.example +++ b/config/env.example @@ -5,11 +5,11 @@ SOURCE="tps_local" SECRET_KEY_BASE="05a2d479d8e412198dabd08ef0eee9d6e180f5cbb48661a35fd1cae287f0a93d40b5f1da08f06780d698bbd458a0ea97f730f83ee780de5d4e31f649a0130cf0" SIGNING_KEY="aef3153a9829fa4ba10acb02927ac855df6b92795b1ad265d654443c4b14a017" -DB_DATABASE="" -DB_HOST="" +DB_DATABASE="tps_development" +DB_HOST="localhost" DB_POOL="" -DB_USERNAME="" -DB_PASSWORD="" +DB_USERNAME="tps_development" +DB_PASSWORD="tps_development" BASIC_AUTH_ENABLED="" BASIC_AUTH_USERNAME="" From 6d153dce464a2804b8ff8c344b6893ae1440d21d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 15:59:27 +0200 Subject: [PATCH 05/15] Populate some env vars --- config/env.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/env.example b/config/env.example index 626b69355..60726e0a7 100644 --- a/config/env.example +++ b/config/env.example @@ -11,7 +11,7 @@ DB_POOL="" DB_USERNAME="tps_development" DB_PASSWORD="tps_development" -BASIC_AUTH_ENABLED="" +BASIC_AUTH_ENABLED="disabled" BASIC_AUTH_USERNAME="" BASIC_AUTH_PASSWORD="" @@ -39,7 +39,7 @@ HELPSCOUT_CLIENT_ID="" HELPSCOUT_CLIENT_SECRET="" HELPSCOUT_WEBHOOK_SECRET="" -SENTRY_ENABLED="" +SENTRY_ENABLED="disabled" SENTRY_DSN_RAILS="" SENTRY_DSN_JS="" @@ -56,4 +56,4 @@ PIPEDRIVE_KEY="" SKYLIGHT_AUTHENTICATION_KEY="" -LOGRAGE_ENABLED="" +LOGRAGE_ENABLED="disabled" From 409d4f4b1bcbd5105e7f45849a7f1fc769416697 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 16:16:07 +0200 Subject: [PATCH 06/15] Remove useless anchor in secrets.yml --- config/secrets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/secrets.yml b/config/secrets.yml index 8b5d5db9f..ec7c25ca0 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -75,5 +75,5 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. -production: &production +production: <<: *defaults From 589127fd4cde84fae3d7ef1e3bdb58541f2392fb Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 16:28:10 +0200 Subject: [PATCH 07/15] Remove now useless secrets --- config/secrets.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/secrets.yml b/config/secrets.yml index ec7c25ca0..b74b8dca6 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -39,7 +39,6 @@ defaults: &defaults openstack_username: <%= ENV['FOG_OPENSTACK_USERNAME'] %> openstack_auth_url: <%= ENV['FOG_OPENSTACK_AUTH_URL'] %> openstack_region: <%= ENV['FOG_OPENSTACK_REGION'] %> - base_url: <%= ENV['FOG_BASE_URL'] %> directory: <%= ENV['FOG_DIRECTORY'] %> mailtrap: username: <%= ENV['MAILTRAP_USERNAME'] %> @@ -60,7 +59,6 @@ test: api_entreprise: key: api_entreprise_test_key fog: - base_url: https://storage.apientreprise.fr directory: tps_dev pipedrive: key: pipedrive_test_key From d05209d28fac74d6a70427b5510a8df11f3b731b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 17:35:14 +0200 Subject: [PATCH 08/15] Make the stats code more robust to empty databases --- app/controllers/stats_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index c37ec9bad..150989e0a 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -82,7 +82,11 @@ class StatsController < ApplicationController total = procedures.count last_30_days_count = procedures.where(published_at: 1.month.ago..Time.now).count previous_count = procedures.where(published_at: 2.months.ago..1.month.ago).count - evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0) + if previous_count != 0 + evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0) + else + evolution = 0 + end formatted_evolution = sprintf("%+d", evolution) { @@ -96,7 +100,11 @@ class StatsController < ApplicationController total = dossiers.count last_30_days_count = dossiers.where(en_construction_at: 1.month.ago..Time.now).count previous_count = dossiers.where(en_construction_at: 2.months.ago..1.month.ago).count - evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0) + if previous_count != 0 + evolution = (((last_30_days_count.to_f / previous_count) - 1) * 100).round(0) + else + evolution = 0 + end formatted_evolution = sprintf("%+d", evolution) { From 2acbef4d761d76c2b9b1988983967ceeb4bbf505 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 18:09:16 +0200 Subject: [PATCH 09/15] Bump default gems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - chartkick (2.3.5 → 3.0.1) - devise (4.4.3 → 4.5.0) - pg (1.0.0 → 1.1.2) - rails (5.2.0 → 5.2.1) - turbolinks (5.1.1 → 5.2.0) - uglifier (4.1.17 → 4.1.18) --- Gemfile.lock | 94 ++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 326a72d48..d96a8b251 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,25 +21,25 @@ GEM CFPropertyList (2.3.6) aasm (5.0.0) concurrent-ruby (~> 1.0) - actioncable (5.2.0) - actionpack (= 5.2.0) + actioncable (5.2.1) + actionpack (= 5.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) + actionmailer (5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.0) - actionview (= 5.2.0) - activesupport (= 5.2.0) + actionpack (5.2.1) + actionview (= 5.2.1) + activesupport (= 5.2.1) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.0) - activesupport (= 5.2.0) + actionview (5.2.1) + activesupport (= 5.2.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -52,24 +52,24 @@ GEM activemodel (>= 4.1, < 6) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (5.2.0) - activesupport (= 5.2.0) + activejob (5.2.1) + activesupport (= 5.2.1) globalid (>= 0.3.6) - activemodel (5.2.0) - activesupport (= 5.2.0) + activemodel (5.2.1) + activesupport (= 5.2.1) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (5.2.0) - activemodel (= 5.2.0) - activesupport (= 5.2.0) + activerecord (5.2.1) + activemodel (= 5.2.1) + activesupport (= 5.2.1) arel (>= 9.0) - activestorage (5.2.0) - actionpack (= 5.2.0) - activerecord (= 5.2.0) + activestorage (5.2.1) + actionpack (= 5.2.1) + activerecord (= 5.2.1) marcel (~> 0.3.1) - activesupport (5.2.0) + activesupport (5.2.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -100,7 +100,7 @@ GEM htmlentities (~> 4.3.1) nokogiri (>= 1.4.1) rubyzip (~> 1.0.0) - bcrypt (3.1.11) + bcrypt (3.1.12) bindata (2.4.3) bindex (0.5.0) bootstrap-sass (3.3.7) @@ -134,7 +134,7 @@ GEM carrierwave-i18n (0.2.0) case_transform (0.2) activesupport - chartkick (2.3.5) + chartkick (3.0.1) childprocess (0.8.0) ffi (~> 1.0, >= 1.0.11) chunky_png (1.3.10) @@ -173,7 +173,7 @@ GEM delayed_job (> 2.0.3) rack-protection (>= 1.5.5) sinatra (>= 1.4.4) - devise (4.4.3) + devise (4.5.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 6.0) @@ -420,7 +420,7 @@ GEM domain_name (~> 0.5) http_parser.rb (0.6.0) httpclient (2.8.3) - i18n (1.0.1) + i18n (1.1.0) concurrent-ruby (~> 1.0) inflecto (0.0.2) ipaddress (0.8.3) @@ -484,7 +484,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mimemagic (0.3.2) - mini_mime (1.0.0) + mini_mime (1.0.1) mini_portile2 (2.3.0) minitest (5.11.3) momentjs-rails (2.20.1) @@ -534,7 +534,7 @@ GEM parser (2.5.1.2) ast (~> 2.4.0) pdf-core (0.7.0) - pg (1.0.0) + pg (1.1.2) powerpack (0.1.2) prawn (2.2.2) pdf-core (~> 0.7.0) @@ -573,18 +573,18 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.0) - actioncable (= 5.2.0) - actionmailer (= 5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) - activemodel (= 5.2.0) - activerecord (= 5.2.0) - activestorage (= 5.2.0) - activesupport (= 5.2.0) + rails (5.2.1) + actioncable (= 5.2.1) + actionmailer (= 5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) + activemodel (= 5.2.1) + activerecord (= 5.2.1) + activestorage (= 5.2.1) + activesupport (= 5.2.1) bundler (>= 1.3.0) - railties (= 5.2.0) + railties (= 5.2.1) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.2) actionpack (~> 5.x, >= 5.0.1) @@ -595,12 +595,12 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) - railties (5.2.0) - actionpack (= 5.2.0) - activesupport (= 5.2.0) + railties (5.2.1) + actionpack (= 5.2.1) + activesupport (= 5.2.1) method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rainbow (3.0.0) raindrops (0.19.0) rake (12.3.1) @@ -751,14 +751,14 @@ GEM timecop (0.9.1) trollop (2.1.2) ttfunk (1.5.1) - turbolinks (5.1.1) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) typhoeus (1.3.0) ethon (>= 0.9.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.17) + uglifier (4.1.18) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext From a6702b5889ea32d0ff66fc7d7ea27f21c5dc6b84 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 18:10:21 +0200 Subject: [PATCH 10/15] Bump development gems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - web-console (3.6.2 → 3.7.0) --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d96a8b251..467e15cf6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -774,7 +774,7 @@ GEM activemodel (>= 3.0.0) addressable vcr (4.0.0) - web-console (3.6.2) + web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) From 4afc5fd4434adb97e40a29d2b1395ac526b88f59 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 3 Sep 2018 18:11:30 +0200 Subject: [PATCH 11/15] Bump test gems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - factory_bot (4.10.0 → 4.11.0) --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 467e15cf6..fb941fcb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -205,7 +205,7 @@ GEM eventmachine (1.2.7) excon (0.62.0) execjs (2.7.0) - factory_bot (4.10.0) + factory_bot (4.11.0) activesupport (>= 3.0.0) faraday (0.12.2) multipart-post (>= 1.2, < 3) From b4aadf43cd41005815e4e3b6389d538fcd5892da Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 3 Sep 2018 13:14:05 +0000 Subject: [PATCH 12/15] initializers: check that env vars declared in env.example are present If an environment variable is declared in `config/env.example`, but not present in the actual environment, the server initialization will raise an exception. Empty strings are allowed (because some values are relevant only in development or production). --- config/initializers/env_vars.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 config/initializers/env_vars.rb diff --git a/config/initializers/env_vars.rb b/config/initializers/env_vars.rb new file mode 100644 index 000000000..9046a8c80 --- /dev/null +++ b/config/initializers/env_vars.rb @@ -0,0 +1,13 @@ +# Ensure that the environment variables defined in the reference env vars file +# are present in the execution environment. +# +# This protects against an out-to-date environment leading to runtime errors. + +if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake' + reference_env_file = File.join('config', 'env.example') + Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, value| + if !ENV.key?(key.to_s) + raise "Configuration error: `#{key}` is not present in the process’ environment variables (declared in `#{reference_env_file}`)" + end + end +end From 49ce7a14c7fa36c595068e6796a97a965227d9c7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 4 Sep 2018 14:52:43 +0200 Subject: [PATCH 13/15] Bump FFI to fix a CVE --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index fb941fcb7..94942b01a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -209,7 +209,7 @@ GEM activesupport (>= 3.0.0) faraday (0.12.2) multipart-post (>= 1.2, < 3) - ffi (1.9.23) + ffi (1.9.25) fission (0.5.0) CFPropertyList (~> 2.2) flipflop (2.4.0) From b2dc502ed59d2105c15b166fabc2dd2b1b30ffe1 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 4 Sep 2018 14:43:03 +0200 Subject: [PATCH 14/15] Use an env var for Carrierwave's cache_dir --- app/uploaders/base_uploader.rb | 6 +----- config/env.example | 1 + config/secrets.yml | 4 ++++ spec/uploaders/base_uploader_spec.rb | 12 +----------- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/app/uploaders/base_uploader.rb b/app/uploaders/base_uploader.rb index 279e3ced6..1c0270db0 100644 --- a/app/uploaders/base_uploader.rb +++ b/app/uploaders/base_uploader.rb @@ -1,9 +1,5 @@ class BaseUploader < CarrierWave::Uploader::Base def cache_dir - if Rails.env.production? - '/tmp/tps-cache' - else - '/tmp/tps-dev-cache' - end + Rails.application.secrets.carrierwave[:cache_dir] end end diff --git a/config/env.example b/config/env.example index 60726e0a7..815202e99 100644 --- a/config/env.example +++ b/config/env.example @@ -22,6 +22,7 @@ FOG_OPENSTACK_AUTH_URL="" FOG_OPENSTACK_REGION="" FOG_DIRECTORY="" FOG_ENABLED="" +CARRIERWAVE_CACHE_DIR="/tmp/tps-local-cache" CLEVER_CLOUD_ACCESS_KEY_ID="" CLEVER_CLOUD_SECRET_ACCESS_KEY="" diff --git a/config/secrets.yml b/config/secrets.yml index b74b8dca6..5c4ad5598 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -40,6 +40,8 @@ defaults: &defaults openstack_auth_url: <%= ENV['FOG_OPENSTACK_AUTH_URL'] %> openstack_region: <%= ENV['FOG_OPENSTACK_REGION'] %> directory: <%= ENV['FOG_DIRECTORY'] %> + carrierwave: + cache_dir: <%= ENV['CARRIERWAVE_CACHE_DIR'] %> mailtrap: username: <%= ENV['MAILTRAP_USERNAME'] %> password: <%= ENV['MAILTRAP_PASSWORD'] %> @@ -60,6 +62,8 @@ test: key: api_entreprise_test_key fog: directory: tps_dev + carrierwave: + cache_dir: /tmp/tps-test-cache pipedrive: key: pipedrive_test_key france_connect_particulier: diff --git a/spec/uploaders/base_uploader_spec.rb b/spec/uploaders/base_uploader_spec.rb index 10b0033b0..bee24d096 100644 --- a/spec/uploaders/base_uploader_spec.rb +++ b/spec/uploaders/base_uploader_spec.rb @@ -6,16 +6,6 @@ describe BaseUploader do describe '#cache_dir' do subject { uploader.cache_dir } - context 'when rails env is not production' do - 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 + it { is_expected.to eq '/tmp/tps-test-cache' } end end From a7095b28b4ebcd9958a36ff022530d5fbd398c60 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 4 Sep 2018 14:44:08 +0200 Subject: [PATCH 15/15] Stop using Rails.env.xxx? methods when not relevant --- config/features.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/features.rb b/config/features.rb index 419b5ab43..79288b39f 100644 --- a/config/features.rb +++ b/config/features.rb @@ -26,7 +26,7 @@ Flipflop.configure do feature :remote_storage, default: ENV['FOG_ENABLED'] == 'enabled' feature :weekly_overview, - default: Rails.env.production? + default: ENV['APP_NAME'] == 'tps' end feature :pre_maintenance_mode