Skip to content

Commit

Permalink
Fix missing partner dropdown options of distribution update fail
Browse files Browse the repository at this point in the history
  • Loading branch information
coalest committed Dec 12, 2024
1 parent 9f306ac commit 65d2811
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/distributions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def update
@distribution.line_items.build if @distribution.line_items.size.zero?
@distribution.initialize_request_items
@items = current_organization.items.alphabetized
@partner_list = current_organization.partners.alphabetized
@storage_locations = current_organization.storage_locations.active_locations.alphabetized
render :edit
end
Expand Down
14 changes: 12 additions & 2 deletions spec/requests/distributions_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,10 @@
include_examples "requiring authorization"
end

describe "POST #update" do
describe "PATCH #update" do
let(:partner_name) { "Patrick" }
let(:location) { create(:storage_location, organization: organization) }
let(:partner) { create(:partner, organization: organization) }
let(:partner) { create(:partner, name: partner_name, organization: organization) }

let(:distribution) { create(:distribution, partner: partner, organization: organization) }
let(:issued_at) { distribution.issued_at }
Expand Down Expand Up @@ -518,6 +519,15 @@
expect(flash[:error]).to include("Distribution date and time can't be blank")
expect(response).not_to redirect_to(anything)
end

it "renders storage location dropdowns" do
patch distribution_path(distribution_params)

page = Nokogiri::HTML(response.body)
selectable_partners = page.at_css("select#distribution_partner_id").text.split("\n")

expect(selectable_partners).to include("Patrick")
end
end

describe "when changing storage location" do
Expand Down

0 comments on commit 65d2811

Please sign in to comment.