diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb index b898201db..3f01f7148 100644 --- a/spec/models/drop_down_list_spec.rb +++ b/spec/models/drop_down_list_spec.rb @@ -47,16 +47,16 @@ describe DropDownList do end context 'when multiple' do - let(:type_de_champ) { TypeDeChamp.new(type_champ: 'multiple_drop_down_list') } + let(:type_de_champ) { build(:type_de_champ_public, type_champ: 'multiple_drop_down_list') } + let(:champ) { type_de_champ.champ.build(value: '["1","2"]').decorate } - let(:champ) { Champ.new(value: '["1","2"]').decorate } it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) } end context 'when simple' do - let(:type_de_champ) { TypeDeChamp.new(type_champ: 'drop_down_list') } + let(:type_de_champ) { build(:type_de_champ_public, type_champ: 'drop_down_list') } + let(:champ) { type_de_champ.champ.build(value: '1').decorate } - let(:champ) { Champ.new(value: '1').decorate } it { expect(dropdownlist.selected_options(champ)).to match(['1']) } end end diff --git a/spec/services/champs_service_spec.rb b/spec/services/champs_service_spec.rb index 2912da0e9..108596113 100644 --- a/spec/services/champs_service_spec.rb +++ b/spec/services/champs_service_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe ChampsService do - let!(:champ) { Champ.create(value: 'toto', type_de_champ: TypeDeChamp.new) } - let!(:champ_mandatory_empty) { Champ.create(type_de_champ: TypeDeChamp.new(libelle: 'mandatory', mandatory: true)) } - let!(:champ_datetime) do - champ_datetime = TypeDeChamp.new(type_champ: 'datetime') - Champ.create(type_de_champ: champ_datetime) - end + let(:type_de_champ) { create(:type_de_champ_public) } + let(:type_de_champ_mandatory) { create(:type_de_champ_public, libelle: 'mandatory', mandatory: true) } + let(:type_de_champ_datetime) { create(:type_de_champ_public, type_champ: :datetime) } + let!(:champ) { type_de_champ.champ.create(value: 'toto') } + let!(:champ_mandatory_empty) { type_de_champ_mandatory.champ.create } + let!(:champ_datetime) { type_de_champ_datetime.champ.create } let!(:champs) { [champ, champ_mandatory_empty, champ_datetime] } describe 'save_champs' do