|
161 | 161 | create(:donation_site, organization: organization) |
162 | 162 | create(:product_drive, organization: organization) |
163 | 163 | create(:product_drive_participant, organization: organization) |
| 164 | + create(:product_drive_participant, organization: organization, contact_name: "contact without business name", business_name: "") |
164 | 165 | create(:manufacturer, organization: organization) |
165 | 166 | organization.reload |
166 | 167 | end |
|
248 | 249 | end.to change { Donation.count }.by(1) |
249 | 250 | end |
250 | 251 |
|
| 252 | + it "Displays ProductDrive Participants sources by business name then contact name" 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 | + |
251 | 258 | it "Allows User to create a Product Drive from donation" do |
252 | 259 | select Donation::SOURCES[:product_drive], from: "donation_source" |
253 | 260 | select "---Create new Product Drive---", from: "donation_product_drive_id" |
|
273 | 280 | fill_in "product_drive_participant_email", with: "123@mail.ru" |
274 | 281 | fill_in "product_drive_participant_comment", with: "test comment" |
275 | 282 | click_on "product-drive-participant-submit" |
| 283 | + expect(page).to have_select('donation_product_drive_participant_id', with_options: ['businesstest']) |
| 284 | + |
276 | 285 | select "businesstest", from: "donation_product_drive_participant_id" |
277 | 286 | end |
278 | 287 |
|
| 288 | + # seems like a duplicate check but this update happens via JS, so we have to test that code works too |
| 289 | + it "Renders ProductDrive Participants sources by business name then contact name after creating a participant" do |
| 290 | + select Donation::SOURCES[:product_drive], from: "donation_source" |
| 291 | + select "---Create new Participant---", from: "donation_product_drive_participant_id" |
| 292 | + |
| 293 | + find(".modal-content") |
| 294 | + expect(page).to have_content("New Product Drive Participant") |
| 295 | + |
| 296 | + fill_in "product_drive_participant_business_name", with: "" |
| 297 | + fill_in "product_drive_participant_contact_name", with: "2nd contact without business name" |
| 298 | + fill_in "product_drive_participant_email", with: "1233@mail.ru" |
| 299 | + fill_in "product_drive_participant_comment", with: "test comment" |
| 300 | + click_on "product-drive-participant-submit" |
| 301 | + |
| 302 | + select ProductDrive.first.name, from: "donation_product_drive_id" |
| 303 | + # note that I'm not explicitly testing the business name here, this is handled in the previous test |
| 304 | + expect(page).to have_select('donation_product_drive_participant_id', with_options: ['2nd contact without business name']) |
| 305 | + end |
| 306 | + |
279 | 307 | it "Allows User to create a donation for a Manufacturer source" do |
280 | 308 | select Donation::SOURCES[:manufacturer], from: "donation_source" |
281 | 309 | expect(page).to have_xpath("//select[@id='donation_manufacturer_id']") |
|
0 commit comments