feat(routing): ui side: prevent changing tdc type if used for routing
This commit is contained in:
parent
c1f67499aa
commit
9ea75a5bd1
2 changed files with 31 additions and 1 deletions
|
@ -30,7 +30,7 @@
|
|||
%span.sr-only Déplacer le champ vers le bas
|
||||
.cell.flex.justify-start.column.flex-grow
|
||||
= form.label :type_champ, "Type de champ", for: dom_id(type_de_champ, :type_champ)
|
||||
= form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ)
|
||||
= form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ), disabled: coordinate.used_by_routing_rules?
|
||||
.flex.column.justify-start.flex-grow
|
||||
.cell
|
||||
.flex.align-center
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
describe TypesDeChampEditor::ChampComponent, type: :component do
|
||||
describe 'render' do
|
||||
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :drop_down_list, libelle: 'Votre ville', options: ['Paris', 'Lyon', 'Marseille'] }]) }
|
||||
let(:drop_down_tdc) { procedure.draft_revision.types_de_champ.first }
|
||||
let(:coordinate) { drop_down_tdc.revision_type_de_champ }
|
||||
let(:component) { described_class.new(coordinate:, upper_coordinates: []) }
|
||||
let(:routing_rules_stable_ids) { [] }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(Procedure).to receive(:stable_ids_used_by_routing_rules).and_return(routing_rules_stable_ids)
|
||||
render_inline(component)
|
||||
end
|
||||
|
||||
context 'drop down tdc not used for routing' do
|
||||
it do
|
||||
expect(page).not_to have_text(/utilisé pour\nle routage/)
|
||||
expect(page).not_to have_css("select[disabled=\"disabled\"]")
|
||||
end
|
||||
end
|
||||
|
||||
context 'drop down tdc used for routing' do
|
||||
let(:routing_rules_stable_ids) { [drop_down_tdc.stable_id] }
|
||||
|
||||
it do
|
||||
expect(page).to have_css("select[disabled=\"disabled\"]")
|
||||
expect(page).to have_text(/utilisé pour\nle routage/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue