Skip to content

Commit

Permalink
wip fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
lisa-durand authored and E-L-T committed Dec 20, 2024
1 parent a00a156 commit 22a9cc2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions spec/models/champ_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,11 @@
end

context 'for drop down list champ' do
let(:champ) { Champs::DropDownListChamp.new(value:) }
before { allow(champ).to receive(:type_de_champ).and_return(build(:type_de_champ_drop_down_list)) }
let(:champ) { Champs::DropDownListChamp.new() }
before do
allow(champ).to receive(:type_de_champ).and_return(build(:type_de_champ_drop_down_list))
champ.value = value
end
let(:value) { "val1" }

it { is_expected.to eq([value]) }
Expand Down
6 changes: 4 additions & 2 deletions spec/models/champs/drop_down_list_champ_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
describe Champs::DropDownListChamp do
describe 'validations' do
describe 'inclusion' do
let(:champ) { described_class.new(other:, value:, dossier: build(:dossier)) }
let(:champ) { described_class.new(other:, dossier: create(:dossier)) }
before do
allow(champ).to receive(:type_de_champ).and_return(build(:type_de_champ_drop_down_list, drop_down_other: other))
type_de_champ = build(:type_de_champ_drop_down_list, drop_down_other: other)
allow(champ).to receive(:type_de_champ).and_return(type_de_champ)
allow(champ).to receive(:in_dossier_revision?).and_return(true)
champ.value = value
end
subject { champ.validate(:champs_public_value) }

Expand Down
7 changes: 6 additions & 1 deletion spec/models/logic/champ_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@

context 'dropdown tdc' do
let(:tdc_type) { :drop_down_list }
let(:champ) { Champs::DropDownListChamp.new(value:, other:, stable_id: tdc.stable_id, dossier:) }
let(:champ) { Champs::DropDownListChamp.new(other:, stable_id: tdc.stable_id, dossier:) }
let(:value) { 'val1' }
let(:other) { nil }

before do
champ.value = value
end

it { expect(champ_value(champ.stable_id).type([champ.type_de_champ])).to eq(:enum) }
it { is_expected.to eq('val1') }
it { expect(champ_value(champ.stable_id).options([champ.type_de_champ])).to match_array([["val1", "val1"], ["val2", "val2"], ["val3", "val3"]]) }
Expand All @@ -81,6 +85,7 @@

context 'with other filled' do
let(:other) { true }
let(:value) { Champs::DropDownListChamp::OTHER }

it { is_expected.to eq(Champs::DropDownListChamp::OTHER) }
end
Expand Down

0 comments on commit 22a9cc2

Please sign in to comment.