Skip to content

Commit

Permalink
Make purchase helper pick default storage location
Browse files Browse the repository at this point in the history
Changed the purchase helper to use the default storage location
of the organization first, before using any other storage locations
that are available.

Also added a (failing) spec to check that we can see the option
on the page. Should be fixed in the next commit
  • Loading branch information
lenikadali committed Oct 14, 2024
1 parent 140bbfe commit bf3a652
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/purchases_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ def purchased_from(purchase)
end

def new_purchase_default_location(purchase)
purchase.storage_location_id.presence || current_organization.intake_location
current_organization.default_storage_location || purchase.storage_location_id.presence || current_organization.intake_location
end
end
3 changes: 3 additions & 0 deletions spec/requests/purchases_requests_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RSpec.describe "Purchases", type: :request do
let(:organization) { create(:organization) }
let(:storage_location) { create(:storage_location, organization: organization) }
let(:user) { create(:user, organization: organization) }
let(:organization_admin) { create(:organization_admin, organization: organization) }

Expand Down Expand Up @@ -48,11 +49,13 @@

describe "GET #new" do
subject do
organization.update!(default_storage_location: storage_location)
get new_purchase_path
response
end

it { is_expected.to be_successful }
it { is_expected.to include(storage_location.name) }
end

describe "POST#create" do
Expand Down

0 comments on commit bf3a652

Please sign in to comment.