dawarich/spec/jobs/trips/create_path_job_spec.rb

24 lines
536 B
Ruby
Raw Normal View History

2025-01-24 09:58:44 -05:00
# frozen_string_literal: true
2025-01-24 06:01:54 -05:00
require 'rails_helper'
RSpec.describe Trips::CreatePathJob, type: :job do
2025-01-24 09:58:44 -05:00
let!(:trip) { create(:trip, :with_points) }
let(:points) { trip.points }
let(:trip_path) do
"LINESTRING (#{points.map do |point|
"#{point.lon.to_f.round(5)} #{point.lat.to_f.round(5)}"
2025-01-24 09:58:44 -05:00
end.join(', ')})"
end
before do
trip.update(path: nil, distance: nil)
end
it 'creates a path for a trip' do
described_class.perform_now(trip.id)
expect(trip.reload.path.to_s).to eq(trip_path)
end
2025-01-24 06:01:54 -05:00
end