From e4e64ec82fd59843064a75a50483b441860e2f1d Mon Sep 17 00:00:00 2001 From: dripsmvcp <138900956+dripsmvcp@users.noreply.github.com> Date: Fri, 5 Jun 2026 10:28:43 +0900 Subject: [PATCH] fix(sharing): scope import account selects to accessible_by (#1803) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three CSV / QIF account selects in import/uploads/show.html.erb and one PDF-import account select in imports/_pdf_import.html.erb pulled their options from `@import.family.accounts`. That listed every account in the family — including the family admin's unshared personal accounts — in the dropdown shown to any member running an import. Swap each call site to `Current.user.accessible_accounts` (owned + explicitly shared accounts only), matching the existing scoping used by the dashboard sidebar, transactions controller, transfers controller, etc. Adds a regression test that signs in as family_member and asserts the unshared-account names from the dylan_family fixtures never appear in the rendered upload page. --- app/views/import/uploads/show.html.erb | 6 +++--- app/views/imports/_pdf_import.html.erb | 2 +- .../import/uploads_controller_test.rb | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/views/import/uploads/show.html.erb b/app/views/import/uploads/show.html.erb index 7cf51d651..7d19818c6 100644 --- a/app/views/import/uploads/show.html.erb +++ b/app/views/import/uploads/show.html.erb @@ -56,7 +56,7 @@ <%= styled_form_with model: @import, scope: :import, url: import_upload_path(@import), multipart: true, class: "space-y-4" do |form| %> <%= form.select :account_id, - @import.family.accounts.visible.alphabetically.pluck(:name, :id), + Current.user.accessible_accounts.visible.alphabetically.pluck(:name, :id), { label: t(".qif_account_label"), include_blank: t(".qif_account_placeholder"), selected: @import.account_id }, required: true %> @@ -112,7 +112,7 @@ <%= form.select :col_sep, Import.separator_options, label: true %> <% if @import.type == "TransactionImport" || @import.type == "TradeImport" %> - <%= form.select :account_id, @import.family.accounts.visible.alphabetically.pluck(:name, :id), { label: t(".account_optional_label"), include_blank: t(".multi_account_import"), selected: @import.account_id } %> + <%= form.select :account_id, Current.user.accessible_accounts.visible.alphabetically.pluck(:name, :id), { label: t(".account_optional_label"), include_blank: t(".multi_account_import"), selected: @import.account_id } %> <% end %>