Merge pull request #8306 from demarches-simplifiees/remove-feature-flag-zonage

Remove feature flag zonage
This commit is contained in:
krichtof 2022-12-21 09:20:06 +01:00 committed by GitHub
commit b996e7f786
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 38 additions and 13 deletions

View file

@ -653,7 +653,7 @@ class Procedure < ApplicationRecord
end
def missing_zones?
if feature_enabled?(:zonage)
if Rails.application.config.ds_zonage_enabled
zones.empty?
else
false

View file

@ -2,4 +2,5 @@
%nav#header-navigation.fr-nav{ role: 'navigation', 'aria-label': 'Menu principal administrateur' }
%ul.fr-nav__list
%li.fr-nav__item= link_to 'Mes démarches', admin_procedures_path, class:'fr-nav__link', 'aria-current': current_page?(admin_procedures_path) ? 'page' : nil
%li.fr-nav__item= link_to 'Toutes les démarches', all_admin_procedures_path(zone_ids: current_administrateur.zones), class:'fr-nav__link', 'aria-current': current_page?(all_admin_procedures_path) ? 'page' : nil
- if Rails.application.config.ds_zonage_enabled
%li.fr-nav__item= link_to 'Toutes les démarches', all_admin_procedures_path(zone_ids: current_administrateur.zones), class:'fr-nav__link', 'aria-current': current_page?(all_admin_procedures_path) ? 'page' : nil

View file

@ -58,7 +58,7 @@
%h2.fr-mt-5w.fr-mb-3w.fr-h1 Indispensable avant publication
.fr-grid-row.fr-grid-row--gutters
= render Procedure::Card::PresentationComponent.new(procedure: @procedure)
= render Procedure::Card::ZonesComponent.new(procedure: @procedure) if @procedure.feature_enabled?(:zonage)
= render Procedure::Card::ZonesComponent.new(procedure: @procedure) if Rails.application.config.ds_zonage_enabled
= render Procedure::Card::ChampsComponent.new(procedure: @procedure)
= render Procedure::Card::ServiceComponent.new(procedure: @procedure, administrateur: current_administrateur)
= render Procedure::Card::AdministrateursComponent.new(procedure: @procedure)

View file

@ -13,7 +13,7 @@
= f.label :zone do
= t('zone', scope: 'activerecord.attributes.procedure')
- if @procedure.feature_enabled?(:zonage)
- if Rails.application.config.ds_zonage_enabled
= f.collection_check_boxes :zone_ids, Zone.available_at(@procedure.published_or_created_at), :id, :label do |b|
.editable-champ.editable-champ-checkbox
= b.check_box

View file

@ -77,6 +77,8 @@ module TPS
config.ds_opendata_enabled = ENV.fetch('OPENDATA_ENABLED', nil) == 'enabled'
config.ds_zonage_enabled = ENV.fetch("ZONAGE_ENABLED", nil) == "enabled"
config.skylight.probes += [:graphql]
# Custom Configuration

View file

@ -149,6 +149,10 @@ DATAGOUV_API_URL="https://www.data.gouv.fr/api/1"
DATAGOUV_DESCRIPTIF_DEMARCHES_DATASET="datasetid"
DATAGOUV_DESCRIPTIF_DEMARCHES_RESOURCE="resourceid"
# Zonage
ZONAGE_ENABLED='enabled' # zonage disabled by default if `ZONAGE_ENABLED` not set
# SAML
SAML_IDP_CERTIFICATE="idpcertificate"
SAML_IDP_SECRET_KEY="-----BEGIN RSA PRIVATE KEY-----\nblabla+blabla\n-----END RSA PRIVATE KEY-----\n"

View file

@ -80,6 +80,8 @@ Rails.application.configure do
status_visible_duration: 500
}
config.ds_zonage_enabled = true
# BCrypt is slow by design - but during tests we want to make it faster
# to compute hashes of passwords.
silence_warnings do

View file

@ -450,8 +450,8 @@ Rails.application.routes.draw do
collection do
get 'new_from_existing'
post 'search'
get 'all'
get 'administrateurs'
get 'all' if Rails.application.config.ds_zonage_enabled
get 'administrateurs' if Rails.application.config.ds_zonage_enabled
end
member do

View file

@ -1,7 +1,7 @@
namespace :after_party do
desc 'Deployment task: populate_zones'
task populate_zones: :environment do
if Flipper.enabled? :zonage
if Rails.application.config.ds_zonage_enabled
puts "Running deploy task 'populate_zones'"
collectivite = Zone.find_or_create_by!(acronym: 'COLLECTIVITE')
coll_label = collectivite.labels.find_or_initialize_by(designated_on: Date.parse('1977-07-30'))

View file

@ -116,6 +116,15 @@ FactoryBot.define do
end
end
trait :with_zone do
zones {
[
create(:zone, labels:
[{ designated_on: Time.zone.now, name: "Ministère 1" }])
]
}
end
trait :routee do
after(:create) do |procedure, _evaluator|
procedure.groupe_instructeurs.create(label: 'deuxième groupe')

View file

@ -1243,7 +1243,7 @@ describe Procedure do
describe '.missing_zones?' do
before do
Flipper.enable :zonage
Rails.application.config.ds_zonage_enabled = true
end
let(:procedure) { create(:procedure, zones: []) }

View file

@ -5,7 +5,7 @@ describe 'As an administrateur, I want to manage the procedures attestation',
let(:administrateur) { create(:administrateur) }
let(:procedure) do
create(:procedure, :with_service, :with_instructeur,
create(:procedure, :with_service, :with_instructeur, :with_zone,
aasm_state: :brouillon,
administrateurs: [administrateur],
libelle: 'libellé de la procédure',

View file

@ -6,7 +6,7 @@ describe 'As an administrateur I wanna clone a procedure', js: true do
let(:administrateur) { create(:administrateur) }
before do
create(:procedure, :with_service, :with_instructeur,
create(:procedure, :with_service, :with_instructeur, :with_zone,
aasm_state: :publiee,
administrateurs: [administrateur],
libelle: 'libellé de la procédure',
@ -29,6 +29,11 @@ describe 'As an administrateur I wanna clone a procedure', js: true do
find("#service .fr-btn").click
click_on "Assigner"
# select zone
find("#zones .fr-btn").click
check Zone.last.current_label
click_on 'Enregistrer'
# then publish
find('#publish-procedure-link').click
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure'

View file

@ -10,6 +10,7 @@ describe 'Publishing a procedure', js: true do
:with_path,
:with_type_de_champ,
:with_service,
:with_zone,
instructeurs: instructeurs,
administrateur: administrateur)
end
@ -51,6 +52,7 @@ describe 'Publishing a procedure', js: true do
create(:procedure,
:with_path,
:with_service,
:with_zone,
instructeurs: instructeurs,
administrateur: administrateur,
types_de_champ_public: [{ type: :repetition, libelle: 'Enfants', children: [] }, { type: :drop_down_list, libelle: 'Civilité', options: [] }],

View file

@ -44,7 +44,7 @@ describe 'fetch API Particulier Data', js: true do
context 'when an administrateur is logged in' do
let(:procedure) do
create(:procedure, :with_service, :with_instructeur,
create(:procedure, :with_service, :with_instructeur, :with_zone,
aasm_state: :brouillon,
administrateurs: [administrateur],
libelle: 'libellé de la procédure',

View file

@ -1,6 +1,6 @@
describe 'The routing', js: true do
let(:password) { 'a very complicated password' }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual) }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual, :with_zone) }
let(:administrateur) { create(:administrateur, procedures: [procedure]) }
let(:scientifique_user) { create(:user, password: password) }
let(:litteraire_user) { create(:user, password: password) }

View file

@ -3,7 +3,7 @@ describe 'administrateurs/procedures/zones.html.haml' do
let(:populate_zones_task) { Rake::Task['after_party:populate_zones'] }
before do
Flipper.enable(:zonage)
Rails.application.config.ds_zonage_enabled = true
populate_zones_task.invoke
end