Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make purchase helper pick default storage location #4722

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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
lenikadali marked this conversation as resolved.
Show resolved Hide resolved

describe "POST#create" do
Expand Down