Merge pull request #8339 from mfo/US/fix-departement-champs

Us/fix departement champs
This commit is contained in:
mfo 2022-12-27 16:01:35 +01:00 committed by GitHub
commit 31735e16d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 4 deletions

View file

@ -9,7 +9,7 @@ describe Champs::DepartementChamp, type: :model do
let(:champ) { described_class.new }
describe 'value', vcr: { cassette_name: 'api_geo_departements' } do
it 'with code' do
it 'with code having 2 chars' do
champ.value = '01'
expect(champ.external_id).to eq('01')
expect(champ.code).to eq('01')
@ -19,6 +19,16 @@ describe Champs::DepartementChamp, type: :model do
expect(champ.to_s).to eq('01 Ain')
end
it 'with code having 3 chars' do
champ.value = '971'
expect(champ.external_id).to eq('971')
expect(champ.code).to eq('971')
expect(champ.name).to eq('Guadeloupe')
expect(champ.value).to eq('Guadeloupe')
expect(champ.selected).to eq('971')
expect(champ.to_s).to eq('971 Guadeloupe')
end
it 'with nil' do
champ.write_attribute(:value, 'Ain')
champ.write_attribute(:external_id, '01')

View file

@ -1669,6 +1669,7 @@ describe Dossier do
end
describe "#destroy" do
before { allow(APIGeoService).to receive(:departement_name).with('01').and_return('Ain') }
let(:procedure) { create(:procedure, :with_all_champs, :with_all_annotations) }
let(:transfer) { create(:dossier_transfer) }
let(:dossier) { create(:dossier, :with_populated_champs, :with_populated_annotations, transfer: transfer, procedure: procedure) }