dawarich/spec/jobs/overland/batch_creating_job_spec.rb

33 lines
796 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2024-04-06 13:09:38 -04:00
require 'rails_helper'
RSpec.describe Overland::BatchCreatingJob, type: :job do
describe '#perform' do
2024-05-25 07:26:56 -04:00
subject(:perform) { described_class.new.perform(json, user.id) }
2024-04-06 13:09:38 -04:00
let(:file_path) { 'spec/fixtures/files/overland/geodata.json' }
2024-04-06 13:09:38 -04:00
let(:file) { File.open(file_path) }
let(:json) { JSON.parse(file.read) }
2024-05-25 07:26:56 -04:00
let(:user) { create(:user) }
2024-04-06 13:09:38 -04:00
it 'creates a location' do
expect { perform }.to change { Point.count }.by(1)
end
2024-05-25 07:26:56 -04:00
it 'creates a point with the correct user_id' do
perform
expect(Point.last.user_id).to eq(user.id)
end
context 'when point already exists' do
it 'does not create a point' do
perform
expect { perform }.not_to(change { Point.count })
end
end
2024-04-06 13:09:38 -04:00
end
end