diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 4258e86ad..6b9ba590c 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -42,7 +42,11 @@ class AccountsController < ApplicationController @q = params.fetch(:q, {}).permit(:search, status: []) entries = @account.entries.where(excluded: false).search(@q).reverse_chronological - @pagy, @entries = pagy(entries, limit: safe_per_page) + @pagy, @entries = pagy( + entries, + limit: safe_per_page, + params: request.query_parameters.except("tab").merge("tab" => "activity") + ) @activity_feed_data = Account::ActivityFeedData.new(@account, @entries) end diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb index c192c278b..39e4dc2e1 100644 --- a/test/controllers/accounts_controller_test.rb +++ b/test/controllers/accounts_controller_test.rb @@ -16,6 +16,27 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest assert_response :success end + test "activity pagination keeps activity tab when loaded from holdings tab" do + investment = accounts(:investment) + + 11.times do |i| + Entry.create!( + account: investment, + name: "Test investment activity #{i}", + date: Date.current - i.days, + amount: 10 + i, + currency: investment.currency, + entryable: Transaction.new + ) + end + + get account_url(investment, tab: "holdings") + + assert_response :success + assert_select "a[href*='page=2'][href*='tab=activity']" + assert_select "a[href*='page=2'][href*='tab=holdings']", count: 0 + end + test "should sync account" do post sync_account_url(@account) assert_redirected_to account_url(@account)