1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00
Maybe/test/controllers/accounts_controller_test.rb
Josh Pigford e7f1506728
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions
Refactor sparkline error handling and improve series pre-loading
- Added pre-loading of series in AccountableSparklinesController and AccountsController to catch errors before rendering.
- Updated the accounts view to use the pre-loaded sparkline series variable.
- Adjusted the test for graceful handling of errors in the sparkline series method.

This enhances the robustness of the sparkline feature and improves error visibility in the UI.
2025-05-26 20:16:07 -05:00

37 lines
960 B
Ruby

require "test_helper"
class AccountsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
@account = accounts(:depository)
end
test "should get index" do
get accounts_url
assert_response :success
end
test "should sync account" do
post sync_account_url(@account)
assert_redirected_to account_url(@account)
end
test "should get chart" do
get chart_account_url(@account)
assert_response :success
end
test "should get sparkline" do
get sparkline_account_url(@account)
assert_response :success
end
test "should handle sparkline errors gracefully" do
# Mock an error in the balance_series method to bypass the rescue in sparkline_series
Balance::ChartSeriesBuilder.any_instance.stubs(:balance_series).raises(StandardError.new("Test error"))
get sparkline_account_url(@account)
assert_response :success
assert_match /Error/, response.body
end
end