dawarich/spec/models/point_spec.rb

37 lines
1.1 KiB
Ruby
Raw Normal View History

2024-05-25 07:26:56 -04:00
# frozen_string_literal: true
2024-03-15 18:27:31 -04:00
require 'rails_helper'
RSpec.describe Point, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:import).optional }
2024-07-12 15:59:03 -04:00
it { is_expected.to belong_to(:user) }
2024-03-15 18:27:31 -04:00
end
describe 'validations' do
it { is_expected.to validate_presence_of(:latitude) }
it { is_expected.to validate_presence_of(:longitude) }
it { is_expected.to validate_presence_of(:timestamp) }
end
2024-07-12 15:59:03 -04:00
describe 'scopes' do
describe '.reverse_geocoded' do
let(:point) { create(:point, country: 'Country', city: 'City') }
let(:point_without_address) { create(:point, city: nil, country: nil) }
it 'returns points with reverse geocoded address' do
expect(described_class.reverse_geocoded).to eq([point])
end
end
describe '.not_reverse_geocoded' do
let(:point) { create(:point, country: 'Country', city: 'City') }
let(:point_without_address) { create(:point, city: nil, country: nil) }
it 'returns points without reverse geocoded address' do
expect(described_class.not_reverse_geocoded).to eq([point_without_address])
end
end
end
2024-03-15 18:27:31 -04:00
end