2021-08-18 14:08:38 +02:00
|
|
|
|
describe Champs::CommuneChamp do
|
|
|
|
|
let(:code_insee) { '63102' }
|
2023-03-21 14:47:31 +01:00
|
|
|
|
let(:code_postal) { '63290' }
|
|
|
|
|
let(:code_departement) { '63' }
|
2023-10-13 16:06:26 +02:00
|
|
|
|
let(:champ) { create(:champ_communes, code_postal:, external_id: code_insee) }
|
2023-03-21 14:47:31 +01:00
|
|
|
|
|
2023-04-13 13:10:23 +02:00
|
|
|
|
describe 'value' do
|
2023-03-21 14:47:31 +01:00
|
|
|
|
it 'with code_postal' do
|
2023-04-05 18:02:42 +02:00
|
|
|
|
expect(champ.to_s).to eq('Châteldon (63290)')
|
|
|
|
|
expect(champ.name).to eq('Châteldon')
|
2023-03-21 14:47:31 +01:00
|
|
|
|
expect(champ.external_id).to eq(code_insee)
|
|
|
|
|
expect(champ.code).to eq(code_insee)
|
|
|
|
|
expect(champ.code_departement).to eq(code_departement)
|
|
|
|
|
expect(champ.code_postal).to eq(code_postal)
|
2024-04-02 17:05:44 +02:00
|
|
|
|
expect(champ.for_export(:value)).to eq 'Châteldon (63290)'
|
|
|
|
|
expect(champ.for_export(:code)).to eq '63102'
|
|
|
|
|
expect(champ.for_export(:departement)).to eq '63 – Puy-de-Dôme'
|
2023-03-21 14:47:31 +01:00
|
|
|
|
expect(champ.communes.size).to eq(8)
|
|
|
|
|
end
|
2022-07-04 15:36:59 +02:00
|
|
|
|
end
|
2023-04-20 10:16:48 +02:00
|
|
|
|
|
|
|
|
|
describe 'code_postal with spaces' do
|
|
|
|
|
let(:code_postal) { ' 63 2 90 ' }
|
|
|
|
|
|
|
|
|
|
it 'with code_postal' do
|
|
|
|
|
expect(champ.communes.size).to eq(8)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-08-18 14:08:38 +02:00
|
|
|
|
end
|