mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Merge pull request #888 from Freika/fix/redo-stats-upon-import-destroy
Fix/redo stats upon import destroy
This commit is contained in:
commit
d6cec7725d
4 changed files with 38 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
- Fixed a bug where background jobs to import Immich and Photoprism geolocation data data could not be created by non-admin users.
|
||||
- Fixed a bug where upon point deletion there was an error it was not being removed from the map, while it was actually deleted from the database. #883
|
||||
- Fixed a bug where upon import deletion stats were not being recalculated. #824
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ImportsController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
@import.destroy!
|
||||
Imports::Destroy.new(current_user, @import).call
|
||||
|
||||
redirect_to imports_url, notice: 'Import was successfully destroyed.', status: :see_other
|
||||
end
|
||||
|
|
|
|||
16
app/services/imports/destroy.rb
Normal file
16
app/services/imports/destroy.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Imports::Destroy
|
||||
attr_reader :user, :import
|
||||
|
||||
def initialize(user, import)
|
||||
@user = user
|
||||
@import = import
|
||||
end
|
||||
|
||||
def call
|
||||
@import.destroy!
|
||||
|
||||
BulkStatsCalculatingJob.perform_later(@user.id)
|
||||
end
|
||||
end
|
||||
20
spec/services/imports/destroy_spec.rb
Normal file
20
spec/services/imports/destroy_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Imports::Destroy do
|
||||
describe '#call' do
|
||||
let!(:user) { create(:user) }
|
||||
let!(:import) { create(:import, user: user) }
|
||||
let(:service) { described_class.new(user, import) }
|
||||
|
||||
it 'destroys the import' do
|
||||
expect { service.call }.to change { Import.count }.by(-1)
|
||||
end
|
||||
|
||||
it 'enqueues a BulkStatsCalculatingJob' do
|
||||
expect(BulkStatsCalculatingJob).to receive(:perform_later).with(user.id)
|
||||
service.call
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue