Use Flipflop instead of Feature
This commit is contained in:
parent
7dd0611a28
commit
45019ce75c
22 changed files with 46 additions and 44 deletions
|
@ -107,7 +107,7 @@ module NewGestionnaire
|
|||
dossier.save
|
||||
|
||||
# needed to force Carrierwave to provide dossier.attestation.pdf.read
|
||||
# when the Feature.remote_storage is true, otherwise pdf.read is a closed stream.
|
||||
# when the Flipflop.remote_storage? is true, otherwise pdf.read is a closed stream.
|
||||
dossier.reload
|
||||
|
||||
attestation_pdf = nil
|
||||
|
|
|
@ -19,7 +19,7 @@ class ProcedureDecorator < Draper::Decorator
|
|||
if logo.blank?
|
||||
h.image_url(LOGO_NAME)
|
||||
else
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
(RemoteDownloader.new logo.filename).url
|
||||
else
|
||||
(LocalDownloader.new logo.path, 'logo').url
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module TypeDeChampHelper
|
||||
def tdc_options(current_administrateur)
|
||||
def tdc_options
|
||||
tdcs = TypeDeChamp.type_de_champs_list_fr
|
||||
|
||||
if !current_administrateur.feature_enabled?(:champ_pj_allowed)
|
||||
if !Flipflop.champ_pj?
|
||||
tdcs.reject! { |tdc| tdc.last == "piece_justificative" }
|
||||
end
|
||||
|
||||
if !current_administrateur.feature_enabled?(:champ_siret_allowed)
|
||||
if !Flipflop.champ_siret?
|
||||
tdcs.reject! { |tdc| tdc.last == "siret" }
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ class WeeklyOverviewJob < ApplicationJob
|
|||
|
||||
def perform(*args)
|
||||
# Feature flipped to avoid mails in staging due to unprocessed dossier
|
||||
if Features.weekly_overview
|
||||
if Flipflop.weekly_overview?
|
||||
Gestionnaire.all
|
||||
.map { |gestionnaire| [gestionnaire, gestionnaire.last_week_overview] }
|
||||
.reject { |_, overview| overview.nil? }
|
||||
|
|
|
@ -11,7 +11,7 @@ class Cerfa < ApplicationRecord
|
|||
|
||||
def content_url
|
||||
if content.url.present?
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
(RemoteDownloader.new content.filename).url
|
||||
else
|
||||
(LocalDownloader.new content.path, 'CERFA').url
|
||||
|
|
|
@ -18,7 +18,7 @@ class Commentaire < ApplicationRecord
|
|||
end
|
||||
|
||||
def file_url
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
RemoteDownloader.new(file.path).url
|
||||
else
|
||||
file.url
|
||||
|
|
|
@ -29,7 +29,7 @@ class PieceJustificative < ApplicationRecord
|
|||
|
||||
def content_url
|
||||
if content.url.present?
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
(RemoteDownloader.new content.filename).url
|
||||
else
|
||||
(LocalDownloader.new content.path,
|
||||
|
|
|
@ -4,7 +4,7 @@ class AttestationTemplateLogoUploader < BaseUploader
|
|||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
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 !Features.remote_storage
|
||||
if !Flipflop.remote_storage?
|
||||
"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 Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
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 !Features.remote_storage
|
||||
if !Flipflop.remote_storage?
|
||||
"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 Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
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 !Features.remote_storage
|
||||
if !Flipflop.remote_storage?
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class CerfaUploader < BaseUploader
|
|||
before :cache, :set_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
storage :fog
|
||||
else
|
||||
storage :file
|
||||
|
@ -11,7 +11,7 @@ class CerfaUploader < 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 !Features.remote_storage
|
||||
if !Flipflop.remote_storage?
|
||||
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ class CerfaUploader < BaseUploader
|
|||
|
||||
def filename
|
||||
if original_filename.present? || model.content_secure_token
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||
else
|
||||
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
|
||||
|
|
|
@ -3,7 +3,7 @@ class CommentaireFileUploader < BaseUploader
|
|||
Rails.root.join("public")
|
||||
end
|
||||
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
storage :fog
|
||||
else
|
||||
storage :file
|
||||
|
|
|
@ -2,7 +2,7 @@ class PieceJustificativeUploader < BaseUploader
|
|||
before :cache, :set_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
storage :fog
|
||||
else
|
||||
storage :file
|
||||
|
@ -11,7 +11,7 @@ class PieceJustificativeUploader < 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 !Features.remote_storage
|
||||
if !Flipflop.remote_storage?
|
||||
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ class PieceJustificativeUploader < BaseUploader
|
|||
|
||||
def filename
|
||||
if original_filename.present? || model.content_secure_token
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||
else
|
||||
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
|
||||
|
|
|
@ -4,7 +4,7 @@ class ProcedureLogoUploader < BaseUploader
|
|||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
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 !Features.remote_storage
|
||||
if !Flipflop.remote_storage?
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ class ProcedureLogoUploader < BaseUploader
|
|||
|
||||
def filename
|
||||
if original_filename.present? || model.logo_secure_token
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||
else
|
||||
filename = "logo-#{secure_token}.#{file.extension.downcase}"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Cette procédure est publiée, certains éléments de la description ne sont plus modifiables
|
||||
|
||||
- { libelle: 'Libellé*', description: 'Description*', organisation: 'Organisme*', direction: 'Direction', lien_site_web: 'Lien site internet', web_hook_url: 'Lien de rappel HTTP' }.each do |key, value|
|
||||
- if key != :web_hook_url || current_administrateur&.feature_enabled?(:web_hook_allowed)
|
||||
- if key != :web_hook_url || Flipflop.web_hook?
|
||||
.form-group
|
||||
%h4
|
||||
= value
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
.form-group.type
|
||||
%h4 Type
|
||||
- tdc_options = tdc_options(current_administrateur)
|
||||
= ff.select :type_champ, tdc_options, {}, { class: 'form-control type-champ' }
|
||||
|
||||
.form-group.description
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require_relative 'features'
|
||||
|
||||
if Rails.env.test?
|
||||
Fog.credentials_path = Rails.root.join('config', 'fog_credentials.test.yml')
|
||||
else
|
||||
|
@ -12,7 +10,7 @@ CarrierWave.configure do |config|
|
|||
config.permissions = 0664
|
||||
config.directory_permissions = 0775
|
||||
|
||||
if Features.remote_storage and not Rails.env.test?
|
||||
if Rails.env.production? || Rails.env.staging?
|
||||
config.fog_credentials = { provider: 'OpenStack' }
|
||||
end
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ describe API::V1::DossiersController do
|
|||
subject { super()[:cerfa].first }
|
||||
|
||||
it { expect(subject[:created_at]).not_to be_nil }
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
it { expect(subject[:content_url]).to match(/^https:\/\/storage.apientreprise.fr\/tps_dev\/cerfa-.*\.pdf$/) }
|
||||
else
|
||||
it { expect(subject[:content_url]).to match(/^http:\/\/.*downloads.*_CERFA\.pdf$/) }
|
||||
|
|
|
@ -200,7 +200,7 @@ shared_examples 'description_controller_spec' do
|
|||
subject { dossier.cerfa.first }
|
||||
|
||||
it 'content' do
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
expect(subject['content']).to eq('cerfa-3dbb3535-5388-4a37-bc2d-778327b9f999.pdf')
|
||||
else
|
||||
expect(subject['content']).to eq('cerfa.pdf')
|
||||
|
|
|
@ -2,19 +2,22 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe TypeDeChampHelper, type: :helper do
|
||||
describe ".tdc_options" do
|
||||
let(:current_administrateur) { create(:administrateur) }
|
||||
let(:pj_option) { ["Pièce justificative", "piece_justificative"] }
|
||||
|
||||
subject { tdc_options(current_administrateur) }
|
||||
subject { tdc_options }
|
||||
|
||||
context "when the champ_pj_allowed_for_admin_id matches the current_administrateur's id" do
|
||||
before { allow(Features).to receive(:champ_pj_allowed_for_admin_ids).and_return([current_administrateur.id]) }
|
||||
context "when the champ_pj is enabled" do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:champ_pj, true)
|
||||
end
|
||||
|
||||
it { is_expected.to include(pj_option) }
|
||||
end
|
||||
|
||||
context "when the champ_pj_allowed_for_admin_id does not match the current_administrateur's id" do
|
||||
before { allow(Features).to receive(:champ_pj_allowed_for_admin_ids).and_return([1000]) }
|
||||
context "when the champ_pj is disabled" do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:champ_pj, false)
|
||||
end
|
||||
|
||||
it { is_expected.not_to include(pj_option) }
|
||||
end
|
||||
|
|
|
@ -7,10 +7,12 @@ RSpec.describe WeeklyOverviewJob, type: :job do
|
|||
let(:mailer_double) { double('mailer', deliver_later: true) }
|
||||
|
||||
context 'if the feature is enabled' do
|
||||
before { allow(Features).to receive(:weekly_overview).and_return(true) }
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:weekly_overview, true)
|
||||
end
|
||||
|
||||
context 'with one gestionnaire with one overview' do
|
||||
before :each do
|
||||
before do
|
||||
expect_any_instance_of(Gestionnaire).to receive(:last_week_overview).and_return(overview)
|
||||
allow(GestionnaireMailer).to receive(:last_week_overview).and_return(mailer_double)
|
||||
WeeklyOverviewJob.new.perform
|
||||
|
@ -21,7 +23,7 @@ RSpec.describe WeeklyOverviewJob, type: :job do
|
|||
end
|
||||
|
||||
context 'with one gestionnaire with no overviews' do
|
||||
before :each do
|
||||
before do
|
||||
expect_any_instance_of(Gestionnaire).to receive(:last_week_overview).and_return(nil)
|
||||
allow(GestionnaireMailer).to receive(:last_week_overview)
|
||||
WeeklyOverviewJob.new.perform
|
||||
|
@ -32,8 +34,8 @@ RSpec.describe WeeklyOverviewJob, type: :job do
|
|||
end
|
||||
|
||||
context 'if the feature is disabled' do
|
||||
before { allow(Features).to receive(:weekly_overview).and_return(false) }
|
||||
before :each do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:weekly_overview, false)
|
||||
allow(Gestionnaire).to receive(:all)
|
||||
WeeklyOverviewJob.new.perform
|
||||
end
|
||||
|
|
|
@ -119,7 +119,7 @@ RSpec.configure do |config|
|
|||
config.before(:all) {
|
||||
Warden.test_mode!
|
||||
|
||||
if Features.remote_storage
|
||||
if Flipflop.remote_storage?
|
||||
VCR.use_cassette("ovh_storage_init") do
|
||||
CarrierWave.configure do |config|
|
||||
config.fog_credentials = { provider: 'OpenStack' }
|
||||
|
|
Loading…
Reference in a new issue