mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 17:51:39 -05:00
Remove unused point creation jobs
This commit is contained in:
parent
620fbba67c
commit
379a5d6f1c
5 changed files with 1 additions and 91 deletions
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Overland::BatchCreatingJob < ApplicationJob
|
||||
queue_as :points
|
||||
|
||||
def perform(params, user_id)
|
||||
Overland::PointsCreator.new(params, user_id).call
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Owntracks::PointCreatingJob < ApplicationJob
|
||||
queue_as :points
|
||||
|
||||
def perform(point_params, user_id)
|
||||
OwnTracks::PointCreator.new(point_params, user_id).call
|
||||
end
|
||||
end
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Overland::BatchCreatingJob, type: :job do
|
||||
describe '#perform' do
|
||||
subject(:perform) { described_class.new.perform(json, user.id) }
|
||||
|
||||
let(:file_path) { 'spec/fixtures/files/overland/geodata.json' }
|
||||
let(:file) { File.open(file_path) }
|
||||
let(:json) { JSON.parse(file.read) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it 'creates a location' do
|
||||
expect { perform }.to change { Point.count }.by(1)
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Owntracks::PointCreatingJob, type: :job do
|
||||
describe '#perform' do
|
||||
subject(:perform) { described_class.new.perform(point_params, user.id) }
|
||||
|
||||
let(:point_params) do
|
||||
{ lat: 1.0, lon: 1.0, tid: 'test', tst: Time.now.to_i, topic: 'iPhone 12 pro' }
|
||||
end
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it 'creates a point' do
|
||||
expect { perform }.to change { Point.count }.by(1)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
context 'when point is invalid' do
|
||||
let(:point_params) { { lat: 1.0, lon: 1.0, tid: 'test', tst: nil, topic: 'iPhone 12 pro' } }
|
||||
|
||||
it 'does not create a point' do
|
||||
expect { perform }.not_to(change { Point.count })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V1::OwnTracks::Points', type: :request do
|
||||
RSpec.describe 'Api::V1::Owntracks::Points', type: :request do
|
||||
describe 'POST /api/v1/owntracks/points' do
|
||||
let(:file_path) { 'spec/fixtures/files/owntracks/2024-03.rec' }
|
||||
let(:json) { OwnTracks::RecParser.new(File.read(file_path)).call }
|
||||
|
|
|
|||
Loading…
Reference in a new issue