Skip to content

Commit 19e54ee

Browse files
authored
Prio source obj's storage loc over org default loc in corrections (#5537)
1 parent df2498d commit 19e54ee

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@ def storage_location_for_source(source_object)
126126
end
127127

128128
def default_location(source_object)
129-
current_organization.default_storage_location || source_object.storage_location_id.presence || current_organization.intake_location
129+
source_object.storage_location_id.presence || current_organization.default_storage_location || current_organization.intake_location
130130
end
131131
end

spec/helpers/application_helper_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ def current_organization; end
151151
it { is_expected.to eq(2) }
152152
end
153153

154+
context "returns source object's storage_location_id even when org has different default" do
155+
let(:organization) { build(:organization, default_storage_location: 42) }
156+
let(:purchase) { build(:purchase, storage_location_id: 1) }
157+
subject { helper.default_location(purchase) }
158+
159+
it { is_expected.to eq(1) }
160+
end
161+
154162
context "returns current_organization intake_location if storage_location_id is not present" do
155163
let(:organization) { build(:organization, intake_location: 1) }
156164
let(:purchase) { build(:purchase, storage_location_id: nil) }

0 commit comments

Comments
 (0)