Skip to content

Commit e4a6f95

Browse files
Brian BonusBrian Bonus
authored andcommitted
bug-4976 Defaults dropdown menu to use contact name when no business name is present
1 parent 2abc01c commit e4a6f95

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

app/views/donations/_donation_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
collection: @product_drive_participants,
4242
selected: donation_form.product_drive_participant_id,
4343
include_blank: true,
44-
label_method: lambda { |x| "#{x.try(:business_name) }" },
44+
label_method: lambda { |x| "#{x.try(:business_name).presence || x.try(:contact_name)}" },
4545
label: "Product Drive Participant",
4646
error: "Which product drive participant was this from?",
4747
wrapper: :input_group %>

spec/system/donation_system_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
create(:donation_site, organization: organization)
162162
create(:product_drive, organization: organization)
163163
create(:product_drive_participant, organization: organization)
164+
create(:product_drive_participant, organization: organization, contact_name: "contact without business name", business_name: "")
164165
create(:manufacturer, organization: organization)
165166
organization.reload
166167
end
@@ -248,6 +249,12 @@
248249
end.to change { Donation.count }.by(1)
249250
end
250251

252+
it "Displays ProductDrive Participants sources by business name then contact name)", :focus => true do
253+
select Donation::SOURCES[:product_drive], from: "donation_source"
254+
select ProductDrive.first.name, from: "donation_product_drive_id"
255+
expect(page).to have_select('donation_product_drive_participant_id', with_options: ['contact without business name'])
256+
end
257+
251258
it "Allows User to create a Product Drive from donation" do
252259
select Donation::SOURCES[:product_drive], from: "donation_source"
253260
select "---Create new Product Drive---", from: "donation_product_drive_id"

0 commit comments

Comments
 (0)