mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-22 14:49:38 +02:00
CSV Imports Overhaul (Transactions, Trades, Accounts, and Mint import support) (#1209)
* Remove stale 1.0 import logic and model * Fresh start * Checkpoint before removing nav * First working prototype * Add trade, account, and mint import flows * Basic working version with tests * System tests for each import type * Clean up mappings flow * Clean up PR, refactor stale code, tests * Add back row validations * Row validations * Fix import job test * Fix import navigation * Fix mint import configuration form * Currency preset for new accounts
This commit is contained in:
parent
23786b444a
commit
398b246965
103 changed files with 2420 additions and 1689 deletions
57
test/interfaces/import_interface_test.rb
Normal file
57
test/interfaces/import_interface_test.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
require "test_helper"
|
||||
|
||||
module ImportInterfaceTest
|
||||
extend ActiveSupport::Testing::Declarative
|
||||
|
||||
test "import interface" do
|
||||
assert_respond_to @subject, :publish
|
||||
assert_respond_to @subject, :publish_later
|
||||
assert_respond_to @subject, :generate_rows_from_csv
|
||||
assert_respond_to @subject, :csv_rows
|
||||
assert_respond_to @subject, :csv_headers
|
||||
assert_respond_to @subject, :csv_sample
|
||||
assert_respond_to @subject, :uploaded?
|
||||
assert_respond_to @subject, :configured?
|
||||
assert_respond_to @subject, :cleaned?
|
||||
assert_respond_to @subject, :publishable?
|
||||
assert_respond_to @subject, :importing?
|
||||
assert_respond_to @subject, :complete?
|
||||
assert_respond_to @subject, :failed?
|
||||
end
|
||||
|
||||
test "publishes later" do
|
||||
import = imports(:transaction)
|
||||
|
||||
import.stubs(:publishable?).returns(true)
|
||||
|
||||
assert_enqueued_with job: ImportJob, args: [ import ] do
|
||||
import.publish_later
|
||||
end
|
||||
|
||||
assert_equal "importing", import.reload.status
|
||||
end
|
||||
|
||||
test "raises if not publishable" do
|
||||
import = imports(:transaction)
|
||||
|
||||
import.stubs(:publishable?).returns(false)
|
||||
|
||||
assert_raises(RuntimeError, "Import is not publishable") do
|
||||
import.publish_later
|
||||
end
|
||||
end
|
||||
|
||||
test "handles publish errors" do
|
||||
import = imports(:transaction)
|
||||
|
||||
import.stubs(:publishable?).returns(true)
|
||||
import.stubs(:import!).raises(StandardError, "Failed to publish")
|
||||
|
||||
assert_nil import.error
|
||||
|
||||
import.publish
|
||||
|
||||
assert_equal "Failed to publish", import.error
|
||||
assert_equal "failed", import.status
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue