Fix tests

This commit is contained in:
Damien Le Thiec 2023-02-21 17:32:24 +01:00
parent 2052bc7840
commit cc2ec995d6
4 changed files with 11 additions and 8 deletions

View file

@ -127,7 +127,7 @@ RSpec.describe PrefillDescription, type: :model do
describe '#prefill_query', vcr: { cassette_name: 'api_geo_regions' } do
let(:procedure) { create(:procedure) }
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
let(:type_de_champ_epci) { TypesDeChamp::PrefillTypeDeChamp.build(create(:type_de_champ_epci, procedure: procedure)) }
let(:type_de_champ_epci) { TypesDeChamp::PrefillTypeDeChamp.build(create(:type_de_champ_epci, procedure: procedure), procedure.active_revision) }
let(:type_de_champ_repetition) { build(:type_de_champ_repetition, :with_types_de_champ, :with_region_types_de_champ, procedure: procedure) }
let(:prefillable_subchamps) { TypesDeChamp::PrefillRepetitionTypeDeChamp.new(type_de_champ_repetition, procedure.active_revision).send(:prefillable_subchamps) }
let(:region_repetition) { prefillable_subchamps.third }

View file

@ -251,7 +251,7 @@ RSpec.describe PrefillParams do
def attributes(champ, value)
TypesDeChamp::PrefillTypeDeChamp
.build(champ.type_de_champ)
.build(champ.type_de_champ, procedure.active_revision)
.to_assignable_attributes(champ, value)
end
end

View file

@ -3,7 +3,7 @@
RSpec.describe TypesDeChamp::PrefillDropDownListTypeDeChamp do
describe '#possible_values' do
let(:procedure) { create(:procedure) }
subject(:possible_values) { described_class.new(type_de_champ).possible_values }
subject(:possible_values) { described_class.new(type_de_champ, procedure.active_revision).possible_values }
before { type_de_champ.reload }
@ -25,8 +25,9 @@ RSpec.describe TypesDeChamp::PrefillDropDownListTypeDeChamp do
end
describe '#example_value' do
let(:type_de_champ) { build(:type_de_champ_drop_down_list) }
subject(:example_value) { described_class.new(type_de_champ).example_value }
let(:procedure) { create(:procedure) }
let(:type_de_champ) { build(:type_de_champ_drop_down_list, procedure: procedure) }
subject(:example_value) { described_class.new(type_de_champ, procedure.active_revision).example_value }
it { expect(example_value).to eq(type_de_champ.drop_down_list_enabled_non_empty_options.first) }
end

View file

@ -1,15 +1,17 @@
# frozen_string_literal: true
RSpec.describe TypesDeChamp::PrefillMultipleDropDownListTypeDeChamp do
let(:procedure) { create(:procedure) }
describe 'ancestors' do
subject { described_class.new(build(:type_de_champ_multiple_drop_down_list)) }
subject { described_class.new(build(:type_de_champ_multiple_drop_down_list, procedure: procedure), procedure.active_revision) }
it { is_expected.to be_kind_of(TypesDeChamp::PrefillDropDownListTypeDeChamp) }
end
describe '#example_value' do
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list, drop_down_list_value: drop_down_list_value) }
subject(:example_value) { described_class.new(type_de_champ).example_value }
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list, drop_down_list_value: drop_down_list_value, procedure: procedure) }
subject(:example_value) { described_class.new(type_de_champ, procedure.active_revision).example_value }
context 'when the multiple drop down list has no option' do
let(:drop_down_list_value) { "" }