Add test got the import job

This commit is contained in:
Stanko K.R.
2026-02-02 13:03:26 +01:00
parent ccbf571be4
commit a6609e1bbc
2 changed files with 34 additions and 8 deletions
+30
View File
@@ -0,0 +1,30 @@
require "test_helper"
class ImportAccountDataJobTest < ActiveJob::TestCase
test "performs import via continuable steps" do
source_account = accounts("37s")
exporter = users(:david)
identity = exporter.identity
export = Account::Export.create!(account: source_account, user: exporter)
export.build
export_tempfile = Tempfile.new([ "export", ".zip" ])
export.file.open { |f| FileUtils.cp(f.path, export_tempfile.path) }
source_account.destroy!
target_account = Account.create_with_owner(account: { name: "Import Test" }, owner: { identity: identity, name: exporter.name })
import = Account::Import.create!(identity: identity, account: target_account)
Current.set(account: target_account) do
import.file.attach(io: File.open(export_tempfile.path), filename: "export.zip", content_type: "application/zip")
end
ImportAccountDataJob.perform_now(import)
assert import.reload.completed?
ensure
export_tempfile&.close
export_tempfile&.unlink
end
end