Merge pull request #3175 from betagouv/frederic/make_champ_pj_generally_available
Make champ pj generally available
This commit is contained in:
commit
77e950568b
6 changed files with 32 additions and 22 deletions
|
@ -2,7 +2,6 @@ class TypesDeChampService
|
|||
include Rails.application.routes.url_helpers
|
||||
|
||||
TOGGLES = {
|
||||
TypeDeChamp.type_champs.fetch(:piece_justificative) => :champ_pj?,
|
||||
TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?,
|
||||
TypeDeChamp.type_champs.fetch(:integer_number) => :champ_integer_number?
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ Flipflop.configure do
|
|||
strategy :default
|
||||
|
||||
group :champs do
|
||||
feature :champ_pj,
|
||||
title: "Champ pièce justificative"
|
||||
feature :champ_siret,
|
||||
title: "Champ SIRET"
|
||||
feature :champ_integer_number,
|
||||
|
@ -28,4 +26,12 @@ Flipflop.configure do
|
|||
feature :pre_maintenance_mode
|
||||
feature :maintenance_mode
|
||||
end
|
||||
|
||||
if Rails.env.test?
|
||||
# It would be nicer to configure this in administrateur_spec.rb in #feature_enabled?,
|
||||
# but that results in a FrozenError: can't modify frozen Hash
|
||||
|
||||
feature :test_a
|
||||
feature :test_b
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace :'2018_05_21_cerfa_to_pj' do
|
|||
|
||||
dossiers.group_by(&:procedure).each do |procedure, dossiers|
|
||||
if !procedure.types_de_champ.find_by(libelle: 'CERFA')
|
||||
procedure.administrateur.enable_feature(:champ_pj)
|
||||
type_de_champ = procedure.types_de_champ.create(
|
||||
type_champ: 'piece_justificative',
|
||||
libelle: 'CERFA'
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: remove_champ_pj_feature'
|
||||
task remove_champ_pj_feature: :environment do
|
||||
rake_puts "Running deploy task 'remove_champ_pj_feature'"
|
||||
|
||||
Administrateur.find_by_sql(
|
||||
<<~SQL
|
||||
SELECT administrateurs.*
|
||||
FROM administrateurs, lateral jsonb_each(features)
|
||||
WHERE key = 'champ_pj'
|
||||
GROUP BY id
|
||||
SQL
|
||||
).each do |admin|
|
||||
admin.features.delete('champ_pj')
|
||||
admin.save
|
||||
end
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181210185634'
|
||||
end
|
||||
end
|
|
@ -65,11 +65,11 @@ describe Administrateur, type: :model do
|
|||
let(:administrateur) { create(:administrateur) }
|
||||
|
||||
before do
|
||||
administrateur.enable_feature(:champ_pj)
|
||||
administrateur.enable_feature(:test_a)
|
||||
end
|
||||
|
||||
it { expect(administrateur.feature_enabled?(:champ_siret)).to be_falsey }
|
||||
it { expect(administrateur.feature_enabled?(:champ_pj)).to be_truthy }
|
||||
it { expect(administrateur.feature_enabled?(:test_b)).to be_falsey }
|
||||
it { expect(administrateur.feature_enabled?(:test_a)).to be_truthy }
|
||||
end
|
||||
|
||||
describe "#password_complexity" do
|
||||
|
|
|
@ -107,20 +107,6 @@ describe TypesDeChampService do
|
|||
|
||||
subject { service.options }
|
||||
|
||||
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 is disabled" do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:champ_pj, false)
|
||||
end
|
||||
|
||||
it { is_expected.not_to include(pj_option) }
|
||||
end
|
||||
it { is_expected.to include(pj_option) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue