Merge pull request #9677 from govpf/feature-ouidou/clone_procedure_with_feature_flags

ETQ admin, les procédures clonées conservent les features flags
This commit is contained in:
Colin Darie 2023-11-28 08:21:02 +00:00 committed by GitHub
commit 64400b512c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View file

@ -539,6 +539,12 @@ class Procedure < ApplicationRecord
.find_by(label: defaut_groupe_instructeur.label) || procedure.groupe_instructeurs.first
procedure.update!(defaut_groupe_instructeur: new_defaut_groupe)
Flipper.features.each do |feature|
if feature_enabled?(feature.key)
Flipper.enable(feature.key, procedure)
end
end
procedure
end

View file

@ -847,6 +847,28 @@ describe Procedure do
expect(subject.canonical_procedure).to be_nil
end
end
describe 'feature flag' do
context 'with a feature flag enabled' do
before do
Flipper.enable(:procedure_routage_api, procedure)
end
it 'should enable feature' do
expect(subject.feature_enabled?(:procedure_routage_api)).to be true
end
end
context 'with a feature flag disabled' do
before do
Flipper.disable(:procedure_routage_api, procedure)
end
it 'should not enable feature' do
expect(subject.feature_enabled?(:procedure_routage_api)).to be false
end
end
end
end
describe '#publish!' do