models: require belong_to associations on geo_area
This commit is contained in:
parent
aff2713032
commit
afb1c33154
3 changed files with 7 additions and 5 deletions
|
@ -12,7 +12,7 @@
|
|||
# geo_reference_id :string
|
||||
#
|
||||
class GeoArea < ApplicationRecord
|
||||
belongs_to :champ
|
||||
belongs_to :champ, optional: false
|
||||
|
||||
store :properties, accessors: [
|
||||
:description,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
FactoryBot.define do
|
||||
factory :geo_area do
|
||||
association :champ
|
||||
|
||||
trait :cadastre do
|
||||
source { GeoArea.sources.fetch(:cadastre) }
|
||||
numero { '42' }
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
RSpec.describe GeoArea, type: :model do
|
||||
describe '#area' do
|
||||
let(:geo_area) { create(:geo_area, :polygon) }
|
||||
let(:geo_area) { build(:geo_area, :polygon) }
|
||||
|
||||
it { expect(geo_area.area).to eq(219.0) }
|
||||
end
|
||||
|
||||
describe '#length' do
|
||||
let(:geo_area) { create(:geo_area, :line_string) }
|
||||
let(:geo_area) { build(:geo_area, :line_string) }
|
||||
|
||||
it { expect(geo_area.length).to eq(30.8) }
|
||||
end
|
||||
|
||||
describe '#location' do
|
||||
let(:geo_area) { create(:geo_area, :point) }
|
||||
let(:geo_area) { build(:geo_area, :point) }
|
||||
|
||||
it { expect(geo_area.location).to eq("2°25'42\"N 46°32'19\"E") }
|
||||
end
|
||||
|
||||
describe '#rgeo_geometry' do
|
||||
let(:geo_area) { create(:geo_area, geometry: geometry) }
|
||||
let(:geo_area) { build(:geo_area, geometry: geometry) }
|
||||
|
||||
context 'invalid' do
|
||||
let(:geometry) do
|
||||
|
|
Loading…
Reference in a new issue