From cd7180c2b21f1e3bac5f72394b95f09eeb5fe3bb Mon Sep 17 00:00:00 2001 From: Cassandra Wallace Date: Mon, 13 Apr 2026 21:00:53 +0200 Subject: [PATCH] Prio source obj's storage loc over org default loc in corrections --- app/helpers/application_helper.rb | 2 +- spec/helpers/application_helper_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c549c6624..4dc6b7b7a5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -126,6 +126,6 @@ def storage_location_for_source(source_object) end def default_location(source_object) - current_organization.default_storage_location || source_object.storage_location_id.presence || current_organization.intake_location + source_object.storage_location_id.presence || current_organization.default_storage_location || current_organization.intake_location end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index cd7e87ddef..8598e2e01a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -151,6 +151,14 @@ def current_organization; end it { is_expected.to eq(2) } end + context "returns source object's storage_location_id even when org has different default" do + let(:organization) { build(:organization, default_storage_location: 42) } + let(:purchase) { build(:purchase, storage_location_id: 1) } + subject { helper.default_location(purchase) } + + it { is_expected.to eq(1) } + end + context "returns current_organization intake_location if storage_location_id is not present" do let(:organization) { build(:organization, intake_location: 1) } let(:purchase) { build(:purchase, storage_location_id: nil) }