dawarich/spec/services/imports/destroy_spec.rb

26 lines
676 B
Ruby
Raw Normal View History

2025-02-15 12:49:30 -05:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Imports::Destroy do
describe '#call' do
let!(:user) { create(:user) }
2025-05-31 15:58:50 -04:00
let!(:import) { create(:import, :with_points, user: user) }
2025-02-15 12:49:30 -05:00
let(:service) { described_class.new(user, import) }
it 'destroys the import' do
expect { service.call }.to change { Import.count }.by(-1)
end
2025-05-31 15:58:50 -04:00
it 'destroys the points' do
expect { service.call }.to change { Point.count }.by(-import.points.count)
end
2025-02-15 12:49:30 -05:00
it 'enqueues a BulkStatsCalculatingJob' do
expect(Stats::BulkCalculator).to receive(:new).with(user.id).and_return(double(call: nil))
2025-02-15 12:49:30 -05:00
service.call
end
end
end