diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index 2c09b70e9..d542ea0e2 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -26,7 +26,7 @@ module ProcedureHelper if logo.blank? ActionController::Base.helpers.image_url("marianne.svg") else - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] RemoteDownloader.new(logo.filename).url else LocalDownloader.new(logo.path, 'logo').url diff --git a/app/jobs/weekly_overview_job.rb b/app/jobs/weekly_overview_job.rb index 7e2a3c83e..2d8c09f65 100644 --- a/app/jobs/weekly_overview_job.rb +++ b/app/jobs/weekly_overview_job.rb @@ -3,7 +3,7 @@ class WeeklyOverviewJob < ApplicationJob def perform(*args) # Feature flipped to avoid mails in staging due to unprocessed dossier - if Flipflop.weekly_overview? + if Rails.application.config.ds_weekly_overview Gestionnaire.all .map { |gestionnaire| [gestionnaire, gestionnaire.last_week_overview] } .reject { |_, overview| overview.nil? } diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index 61e45d5f9..bbf492eba 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -52,7 +52,7 @@ class Commentaire < ApplicationRecord if piece_jointe.virus_scanner.safe? Rails.application.routes.url_helpers.url_for(piece_jointe) end - elsif Flipflop.remote_storage? + elsif Rails.application.secrets.fog[:enabled] RemoteDownloader.new(file.path).url elsif file&.url # FIXME: this is horrible but used only in dev and will be removed after migration diff --git a/app/uploaders/attestation_template_logo_uploader.rb b/app/uploaders/attestation_template_logo_uploader.rb index 49be9500b..a74bc8dc6 100644 --- a/app/uploaders/attestation_template_logo_uploader.rb +++ b/app/uploaders/attestation_template_logo_uploader.rb @@ -4,7 +4,7 @@ class AttestationTemplateLogoUploader < BaseUploader end # Choose what kind of storage to use for this uploader: - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] storage :fog else storage :file @@ -13,7 +13,7 @@ class AttestationTemplateLogoUploader < BaseUploader # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - if !Flipflop.remote_storage? + if !Rails.application.secrets.fog[:enabled] "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end diff --git a/app/uploaders/attestation_template_signature_uploader.rb b/app/uploaders/attestation_template_signature_uploader.rb index 12110868d..50be72cae 100644 --- a/app/uploaders/attestation_template_signature_uploader.rb +++ b/app/uploaders/attestation_template_signature_uploader.rb @@ -4,7 +4,7 @@ class AttestationTemplateSignatureUploader < BaseUploader end # Choose what kind of storage to use for this uploader: - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] storage :fog else storage :file @@ -13,7 +13,7 @@ class AttestationTemplateSignatureUploader < BaseUploader # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - if !Flipflop.remote_storage? + if !Rails.application.secrets.fog[:enabled] "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end diff --git a/app/uploaders/attestation_uploader.rb b/app/uploaders/attestation_uploader.rb index db4304e4a..ddfe1aeab 100644 --- a/app/uploaders/attestation_uploader.rb +++ b/app/uploaders/attestation_uploader.rb @@ -4,7 +4,7 @@ class AttestationUploader < BaseUploader end # Choose what kind of storage to use for this uploader: - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] storage :fog else storage :file @@ -13,7 +13,7 @@ class AttestationUploader < BaseUploader # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - if !Flipflop.remote_storage? + if !Rails.application.secrets.fog[:enabled] "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end diff --git a/app/uploaders/commentaire_file_uploader.rb b/app/uploaders/commentaire_file_uploader.rb index 250cd23d5..93131fb94 100644 --- a/app/uploaders/commentaire_file_uploader.rb +++ b/app/uploaders/commentaire_file_uploader.rb @@ -3,7 +3,7 @@ class CommentaireFileUploader < BaseUploader Rails.root.join("public") end - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] storage :fog else storage :file diff --git a/app/uploaders/procedure_logo_uploader.rb b/app/uploaders/procedure_logo_uploader.rb index 68a110993..0d774d514 100644 --- a/app/uploaders/procedure_logo_uploader.rb +++ b/app/uploaders/procedure_logo_uploader.rb @@ -4,7 +4,7 @@ class ProcedureLogoUploader < BaseUploader end # Choose what kind of storage to use for this uploader: - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] storage :fog else storage :file @@ -13,7 +13,7 @@ class ProcedureLogoUploader < BaseUploader # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - if !Flipflop.remote_storage? + if !Rails.application.secrets.fog[:enabled] "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end @@ -27,7 +27,7 @@ class ProcedureLogoUploader < BaseUploader def filename if file.present? if original_filename.present? || model.logo_secure_token - if Flipflop.remote_storage? + if Rails.application.secrets.fog[:enabled] filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension&.downcase}" else filename = "logo-#{secure_token}.#{file.extension&.downcase}" diff --git a/config/application.rb b/config/application.rb index 97e20adce..be464bbf2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -39,5 +39,7 @@ module TPS # Make main application helpers available in administrate Administrate::ApplicationController.helper(TPS::Application.helpers) end + + config.ds_weekly_overview = ENV['APP_NAME'] == 'tps' end end diff --git a/config/features.rb b/config/features.rb index d4bb54e21..1fa9ba3ee 100644 --- a/config/features.rb +++ b/config/features.rb @@ -29,12 +29,8 @@ Flipflop.configure do end group :production do - feature :remote_storage, - default: ENV['FOG_ENABLED'] == 'enabled' feature :insee_api_v3, default: true - feature :weekly_overview, - default: ENV['APP_NAME'] == 'tps' feature :pre_maintenance_mode feature :maintenance_mode end diff --git a/config/secrets.yml b/config/secrets.yml index 7f3166b96..11001e502 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -34,6 +34,7 @@ defaults: &defaults pipedrive: key: <%= ENV['PIPEDRIVE_KEY'] %> fog: + enabled: <%= ENV['FOG_ENABLED'] == 'enabled' %> openstack_tenant: <%= ENV['FOG_OPENSTACK_TENANT'] %> openstack_api_key: <%= ENV['FOG_OPENSTACK_API_KEY'] %> openstack_username: <%= ENV['FOG_OPENSTACK_USERNAME'] %> diff --git a/spec/jobs/weekly_overview_job_spec.rb b/spec/jobs/weekly_overview_job_spec.rb index b730ec534..abde4e76f 100644 --- a/spec/jobs/weekly_overview_job_spec.rb +++ b/spec/jobs/weekly_overview_job_spec.rb @@ -8,7 +8,10 @@ RSpec.describe WeeklyOverviewJob, type: :job do context 'if the feature is enabled' do before do - Flipflop::FeatureSet.current.test!.switch!(:weekly_overview, true) + Rails.application.config.ds_weekly_overview = true + end + after do + Rails.application.config.ds_weekly_overview = false end context 'with one gestionnaire with one overview' do @@ -35,7 +38,6 @@ RSpec.describe WeeklyOverviewJob, type: :job do context 'if the feature is disabled' do before do - Flipflop::FeatureSet.current.test!.switch!(:weekly_overview, false) allow(Gestionnaire).to receive(:all) WeeklyOverviewJob.new.perform end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cfaa3683c..27dd26382 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -147,14 +147,6 @@ RSpec.configure do |config| Typhoeus::Expectation.clear ActionMailer::Base.deliveries.clear - - if Flipflop.remote_storage? - VCR.use_cassette("ovh_storage_init") do - CarrierWave.configure do |config| - config.fog_credentials = { provider: 'OpenStack' } - end - end - end } RSpec::Matchers.define :have_same_attributes_as do |expected, options|