Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
Loading