Merge pull request #6232 from tchak/fix-carto

Do not crash when properties is nil
This commit is contained in:
Paul Chavard 2021-05-26 12:49:23 +02:00 committed by GitHub
commit 6fbf689f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -22,7 +22,7 @@ class GeoArea < ApplicationRecord
if value.is_a? String
ActiveRecord::Coders::YAMLColumn.new(:properties).load(value)
else
value
value || {}
end
end

View file

@ -100,4 +100,12 @@ RSpec.describe GeoArea, type: :model do
end
end
end
describe 'description' do
context 'when properties is nil' do
let(:geo_area) { build(:geo_area, properties: nil) }
it { expect(geo_area.description).to be_nil }
end
end
end