Put the piece justificative champ behind a feature flag
This commit is contained in:
parent
071c459011
commit
93d8470321
6 changed files with 43 additions and 1 deletions
11
app/helpers/type_de_champ_helper.rb
Normal file
11
app/helpers/type_de_champ_helper.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
module TypeDeChampHelper
|
||||||
|
def tdc_options(current_administrateur)
|
||||||
|
tdcs = TypeDeChamp.type_de_champs_list_fr
|
||||||
|
|
||||||
|
if !current_administrateur.id.in?(Features.champ_pj_allowed_for_admin_ids)
|
||||||
|
tdcs.reject! { |tdc| tdc.last == "piece_justificative" }
|
||||||
|
end
|
||||||
|
|
||||||
|
tdcs
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
.form-group.type
|
.form-group.type
|
||||||
%h4 Type
|
%h4 Type
|
||||||
= ff.select :type_champ, TypeDeChamp.type_de_champs_list_fr, {}, { class: 'form-control type-champ' }
|
- tdc_options = tdc_options(current_administrateur)
|
||||||
|
= ff.select :type_champ, tdc_options, {}, { class: 'form-control type-champ' }
|
||||||
|
|
||||||
.form-group.description
|
.form-group.description
|
||||||
%h4 Description
|
%h4 Description
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
remote_storage: false
|
remote_storage: false
|
||||||
weekly_overview: false
|
weekly_overview: false
|
||||||
|
champ_pj_allowed_for_admin_ids:
|
||||||
|
- 0
|
||||||
|
|
22
spec/helpers/type_de_champ_helper_spec.rb
Normal file
22
spec/helpers/type_de_champ_helper_spec.rb
Normal file
|
@ -0,0 +1,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) }
|
||||||
|
|
||||||
|
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]) }
|
||||||
|
|
||||||
|
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]) }
|
||||||
|
|
||||||
|
it { is_expected.not_to include(pj_option) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,6 +3,9 @@ require 'spec_helper'
|
||||||
describe 'admin/types_de_champ/show.html.haml', type: :view do
|
describe 'admin/types_de_champ/show.html.haml', type: :view do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
|
# FIXME: delete this when support for pj champ is generalized
|
||||||
|
before { allow(view).to receive(:current_administrateur).and_return(create(:administrateur)) }
|
||||||
|
|
||||||
describe 'fields sorted' do
|
describe 'fields sorted' do
|
||||||
let(:first_libelle) { 'salut la compagnie' }
|
let(:first_libelle) { 'salut la compagnie' }
|
||||||
let(:last_libelle) { 'je suis bien sur la page' }
|
let(:last_libelle) { 'je suis bien sur la page' }
|
||||||
|
|
|
@ -3,6 +3,9 @@ require 'spec_helper'
|
||||||
describe 'admin/types_de_champ/show.html.haml', type: :view do
|
describe 'admin/types_de_champ/show.html.haml', type: :view do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
|
# FIXME: delete this when support for pj champ is generalized
|
||||||
|
before { allow(view).to receive(:current_administrateur).and_return(create(:administrateur)) }
|
||||||
|
|
||||||
describe 'fields sorted' do
|
describe 'fields sorted' do
|
||||||
let(:first_libelle) { 'salut la compagnie' }
|
let(:first_libelle) { 'salut la compagnie' }
|
||||||
let(:last_libelle) { 'je suis bien sur la page' }
|
let(:last_libelle) { 'je suis bien sur la page' }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue