The personal finance app for everyone (by everyone)
Ruby
feat: pre-fill new rules with the merchant name (#5336)
matted0ea6acbe0a
diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rbindex 6c904a3589..502ec04c81 100644--- a/app/controllers/transactions_controller.rb+++ b/app/controllers/transactions_controller.rb@@ -181,7 +181,8 @@ class TransactionsController < ApplicationControllerflash[:cta] = {type: "category_rule",category_id: transaction.category_id,- category_name: transaction.category.name+ category_name: transaction.category.name,+ merchant_name: @entry.name}enddiff --git a/test/controllers/transaction_categories_controller_test.rb b/test/controllers/transaction_categories_controller_test.rbindex 2e60292262..cdbbdb2db8 100644--- a/test/controllers/transaction_categories_controller_test.rb+++ b/test/controllers/transaction_categories_controller_test.rb@@ -46,6 +46,7 @@ class TransactionCategoriesControllerTest < ActionDispatch::IntegrationTestassert_response :success# The prompt is rendered into the turbo-stream response (flash is cleared once rendered).assert_match %r{/rules/new\?[^"]*action_value=#{category.id}}, response.body+ assert_match %r{/rules/new\?[^"]*name=AMZN\+Mktp\+UK}, response.bodyendtest "does not offer a rule prompt when an existing rule already covers this transaction" dodiff --git a/test/controllers/transactions_controller_test.rb b/test/controllers/transactions_controller_test.rbindex c9ef120189..3435717f3e 100644--- a/test/controllers/transactions_controller_test.rb+++ b/test/controllers/transactions_controller_test.rb@@ -597,7 +597,7 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTestentryable_attributes: {id: @entry.entryable_id,tag_ids: [ tags(:one).id, tags(:two).id ],- category_id: Category.first.id,+ category_id: categories(:income).id,merchant_id: Merchant.first.id}}@@ -611,12 +611,13 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTestassert_equal "USD", @entry.currencyassert_equal -100, @entry.amountassert_equal [ tags(:one).id, tags(:two).id ].sort, @entry.entryable.tag_ids.sort- assert_equal Category.first.id, @entry.entryable.category_id+ assert_equal categories(:income).id, @entry.entryable.category_idassert_equal Merchant.first.id, @entry.entryable.merchant_idassert_equal "test notes", @entry.notesassert_equal false, @entry.excludedassert_equal "Transaction updated", flash[:notice]+ assert_equal "Updated name", flash[:cta][:merchant_name]assert_redirected_to account_url(@entry.account)assert_enqueued_with(job: SyncJob)end