Merge pull request #4155 from tchak/stop-using-feature-flags-for-env-switch
Stop using feature flags for env switch
This commit is contained in:
commit
fd977a4a84
13 changed files with 20 additions and 27 deletions
|
@ -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
|
||||
|
|
|
@ -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? }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'] %>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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|
|
||||
|
|
Loading…
Add table
Reference in a new issue