add tests for backward compatibility of geo_areas
This commit is contained in:
parent
55080706ce
commit
c5f2faa3d2
2 changed files with 26 additions and 1 deletions
|
@ -5,7 +5,12 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :cadastre do
|
trait :cadastre do
|
||||||
source { GeoArea.sources.fetch(:cadastre) }
|
source { GeoArea.sources.fetch(:cadastre) }
|
||||||
properties { { numero: '42', section: 'A11', commune: '75127' } }
|
properties { { numero: '42', section: 'A11', prefixe: '000', commune: '75127', contenance: '1234', id: '75127000A1142' } }
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :legacy_cadastre do
|
||||||
|
source { GeoArea.sources.fetch(:cadastre) }
|
||||||
|
properties { { numero: '42', section: 'A11', code_com: '127', code_dep: '75', code_arr: '000', surface_parcelle: '1234', surface_intersection: 1234 } }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :selection_utilisateur do
|
trait :selection_utilisateur do
|
||||||
|
|
|
@ -80,4 +80,24 @@ RSpec.describe GeoArea, type: :model do
|
||||||
it { expect(geo_area.valid?).to be_falsey }
|
it { expect(geo_area.valid?).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "cadastre properties" do
|
||||||
|
let(:geo_area) { build(:geo_area, :cadastre) }
|
||||||
|
let(:legacy_geo_area) { build(:geo_area, :legacy_cadastre) }
|
||||||
|
|
||||||
|
it "should be backward compatible" do
|
||||||
|
expect("#{geo_area.code_dep}#{geo_area.code_com}").to eq(geo_area.commune)
|
||||||
|
expect(geo_area.code_arr).to eq(geo_area.prefixe)
|
||||||
|
expect(geo_area.surface_parcelle).to eq(geo_area.surface)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "(legacy)" do
|
||||||
|
it "should be forward compatible" do
|
||||||
|
expect("#{legacy_geo_area.code_dep}#{legacy_geo_area.code_com}").to eq(legacy_geo_area.commune)
|
||||||
|
expect(legacy_geo_area.code_arr).to eq(legacy_geo_area.prefixe)
|
||||||
|
expect(legacy_geo_area.surface_parcelle).to eq(legacy_geo_area.surface)
|
||||||
|
expect(legacy_geo_area.cid).to eq(geo_area.cid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue