demarches-normaliennes/spec/models/champs/commune_champ_spec.rb

37 lines
1.4 KiB
Ruby
Raw Normal View History

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' }
let(:champ) { create(:champ_communes, code_postal:, external_id: code_insee) }
2023-03-21 14:47:31 +01:00
describe 'value' do
2024-05-06 21:44:41 +02:00
it 'find commune' do
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
end
2024-05-06 21:44:41 +02:00
context 'with code' do
let(:champ) { create(:champ_communes, code: '63102-63290') }
2024-05-06 21:44:41 +02:00
it 'find commune' do
expect(champ.to_s).to eq('Châteldon (63290)')
expect(champ.name).to eq('Châteldon')
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)
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'
end
end
end
2021-08-18 14:08:38 +02:00
end