Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Stop holding drawer system tests racing the toast (#4503)

Bhargav Mehtae86b5f347fc5
diff --git a/test/controllers/holdings_controller_test.rb b/test/controllers/holdings_controller_test.rb
index 9faa65fa29..5b295cd7f1 100644
--- a/test/controllers/holdings_controller_test.rb
+++ b/test/controllers/holdings_controller_test.rb
@@ -222,6 +222,7 @@ class HoldingsControllerTest < ActionDispatch::IntegrationTest
# Redirects to account page holdings tab to refresh list
assert_redirected_to account_path(@holding.account, tab: "holdings")
+ assert_equal I18n.t("holdings.unlock_cost_basis.success"), flash[:notice]
@holding.reload
# Then: lock is removed but cost_basis and source remain
@@ -230,6 +231,17 @@ class HoldingsControllerTest < ActionDispatch::IntegrationTest
assert_equal "manual", @holding.cost_basis_source
end
+ test "reset_security restores the provider security and confirms it" do
+ @holding.account.update!(plaid_account: plaid_accounts(:one))
+ @holding.update!(security: securities(:msft), provider_security: securities(:aapl), security_locked: true)
+
+ post reset_security_holding_path(@holding)
+
+ assert_redirected_to account_path(@holding.account, tab: "holdings")
+ assert_equal I18n.t("holdings.reset_security.success"), flash[:notice]
+ assert_equal securities(:aapl), @holding.reload.security
+ end
+
test "remap_security brings offline security back online" do
# Given: the target security is marked offline (e.g. created by a failed QIF import)
msft = securities(:msft)
diff --git a/test/system/holding_drawer_actions_test.rb b/test/system/holding_drawer_actions_test.rb
index 773c1d2d5b..ba63918446 100644
--- a/test/system/holding_drawer_actions_test.rb
+++ b/test/system/holding_drawer_actions_test.rb
@@ -26,7 +26,7 @@ class HoldingDrawerActionsTest < ApplicationSystemTestCase
click_on I18n.t("holdings.show.unlock_cost_basis")
within("#confirm-dialog") { find("button[value=confirm]").click }
- assert_text I18n.t("holdings.unlock_cost_basis.success")
+ assert_current_path account_path(@holding.account, tab: "holdings")
assert_not @holding.reload.cost_basis_locked?
end
@@ -49,7 +49,7 @@ class HoldingDrawerActionsTest < ApplicationSystemTestCase
click_on I18n.t("holdings.show.reset_to_provider")
within("#confirm-dialog") { find("button[value=confirm]").click }
- assert_text I18n.t("holdings.reset_security.success")
+ assert_current_path account_path(@holding.account, tab: "holdings")
assert_equal securities(:aapl), @holding.reload.security
end
end