Fix some tests

This commit is contained in:
Eugene Burmakin 2025-11-17 00:23:48 +01:00
parent e1f16c98a2
commit c462d34efa
2 changed files with 5 additions and 4 deletions

View file

@ -12,10 +12,11 @@ class Place < ApplicationRecord
has_many :place_visits, dependent: :destroy
has_many :suggested_visits, -> { distinct }, through: :place_visits, source: :visit
before_validation :build_lonlat, if: -> { latitude.present? && longitude.present? }
validates :name, presence: true
validates :latitude, :longitude, presence: true
before_validation :build_lonlat, if: -> { latitude.present? && longitude.present? }
validates :lonlat, presence: true
enum :source, { manual: 0, photon: 1 }

View file

@ -47,13 +47,13 @@ RSpec.describe Place, type: :model do
describe '#lon' do
it 'returns the longitude' do
expect(place.lon).to eq(13.0948638)
expect(place.lon).to be_within(0.000001).of(13.0948638)
end
end
describe '#lat' do
it 'returns the latitude' do
expect(place.lat).to eq(54.2905245)
expect(place.lat).to be_within(0.000001).of(54.2905245)
end
end
end