2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-09-07 10:10:07 +02:00
|
|
|
describe 'prefill_descriptions/prefillable_entities.html.haml', type: :view do
|
2023-01-18 09:47:22 +01:00
|
|
|
let(:prefill_description) { PrefillDescription.new(create(:procedure)) }
|
|
|
|
let!(:type_de_champ) { create(:type_de_champ_drop_down_list, procedure: prefill_description, drop_down_options: options) }
|
|
|
|
|
2023-09-07 10:10:07 +02:00
|
|
|
subject { render('prefill_descriptions/prefillable_entities', prefill_description: prefill_description) }
|
2023-01-18 09:47:22 +01:00
|
|
|
|
|
|
|
context 'when a type de champ has too many values' do
|
|
|
|
let(:options) { (1..20).map(&:to_s) }
|
|
|
|
|
|
|
|
it { is_expected.to have_content(type_de_champ.libelle) }
|
|
|
|
|
|
|
|
it { is_expected.to have_link(text: "Voir toutes les valeurs possibles", href: prefill_type_de_champ_path(prefill_description.path, type_de_champ)) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a type de champ does not have too many values' do
|
|
|
|
let(:options) { (1..2).map(&:to_s) }
|
|
|
|
|
|
|
|
it { is_expected.to have_content(type_de_champ.libelle) }
|
|
|
|
|
|
|
|
it { is_expected.not_to have_link(text: "Voir toutes les valeurs possibles", href: prefill_type_de_champ_path(prefill_description.path, type_de_champ)) }
|
|
|
|
end
|
|
|
|
end
|