Do not crash when properties is nil

This commit is contained in:
Paul Chavard 2021-05-26 12:22:35 +02:00
parent a1b48fa1df
commit 4922bc88d6
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