feat: enable features on cloned procedure

This commit is contained in:
seb-by-ouidou 2023-11-07 13:53:32 +00:00 committed by seb-by-ouidou
parent fce2d8efa9
commit c4ca381bed
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