Skip to content

Commit 3908561

Browse files
authored
Fix missing partner dropdown options of distribution update fail (#4868)
1 parent 1e194f0 commit 3908561

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

app/controllers/distributions_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def update
205205
@distribution.line_items.build if @distribution.line_items.size.zero?
206206
@distribution.initialize_request_items
207207
@items = current_organization.items.active.alphabetized
208+
@partner_list = current_organization.partners.alphabetized
208209
@storage_locations = current_organization.storage_locations.active_locations.alphabetized
209210
render :edit
210211
end

spec/requests/distributions_requests_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@
504504
include_examples "requiring authorization"
505505
end
506506

507-
describe "POST #update" do
507+
describe "PATCH #update" do
508+
let(:partner_name) { "Patrick" }
508509
let(:location) { create(:storage_location, organization: organization) }
509-
let(:partner) { create(:partner, organization: organization) }
510+
let(:partner) { create(:partner, name: partner_name, organization: organization) }
510511

511512
let(:distribution) { create(:distribution, partner: partner, organization: organization) }
512513
let(:issued_at) { distribution.issued_at }
@@ -544,6 +545,15 @@
544545
expect(flash[:error]).to include("Distribution date and time can't be blank")
545546
expect(response).not_to redirect_to(anything)
546547
end
548+
549+
it "renders storage location dropdowns" do
550+
patch distribution_path(distribution_params)
551+
552+
page = Nokogiri::HTML(response.body)
553+
selectable_partners = page.at_css("select#distribution_partner_id").text.split("\n")
554+
555+
expect(selectable_partners).to include("Patrick")
556+
end
547557
end
548558

549559
describe "when changing storage location" do

0 commit comments

Comments
 (0)