Merge pull request #5984 from tchak/tests-for-geojson-validation
Ajout de tests automatisés pour la validation des polygones GeoJSON (#5984)
This commit is contained in:
commit
729167b954
2 changed files with 44 additions and 0 deletions
|
@ -57,6 +57,22 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :invalid_right_hand_rule_polygon do
|
||||
geometry do
|
||||
{
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[1.9116157293319704, 49.758172033960115],
|
||||
[1.9116157293319704, 49.758172033960115],
|
||||
[1.91162645816803, 49.75818243044436],
|
||||
[1.9116157293319704, 49.758172033960115]
|
||||
]
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
trait :polygon_with_extra_coordinate do
|
||||
geometry do
|
||||
{
|
||||
|
|
|
@ -52,4 +52,32 @@ RSpec.describe GeoArea, type: :model do
|
|||
it { expect(geo_area.safe_geometry).to eq(polygon) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#valid?' do
|
||||
let(:geo_area) { build(:geo_area, :polygon) }
|
||||
|
||||
context 'polygon' do
|
||||
it { expect(geo_area.valid?).to be_truthy }
|
||||
end
|
||||
|
||||
context 'hourglass_polygon' do
|
||||
let(:geo_area) { build(:geo_area, :hourglass_polygon) }
|
||||
it { expect(geo_area.valid?).to be_falsey }
|
||||
end
|
||||
|
||||
context 'line_string' do
|
||||
let(:geo_area) { build(:geo_area, :line_string) }
|
||||
it { expect(geo_area.valid?).to be_truthy }
|
||||
end
|
||||
|
||||
context 'point' do
|
||||
let(:geo_area) { build(:geo_area, :point) }
|
||||
it { expect(geo_area.valid?).to be_truthy }
|
||||
end
|
||||
|
||||
context 'invalid_right_hand_rule_polygon' do
|
||||
let(:geo_area) { build(:geo_area, :invalid_right_hand_rule_polygon) }
|
||||
it { expect(geo_area.valid?).to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue