|
331 | 331 | end.to change { Request.count }.by(1) |
332 | 332 | end |
333 | 333 |
|
| 334 | + it "does not allow requests to be submitted with duplicate departments." do |
| 335 | + Affiliation.load_from_file(Rails.root.join("spec", "fixtures", "departments.csv")) |
| 336 | + sign_in current_user |
| 337 | + visit "new-project/project-info" |
| 338 | + |
| 339 | + # Non breaking space `u00A0` is at the end of every option to indicate an option was selected |
| 340 | + select "(77777) RDSS-Research Data and Scholarship Services\u00A0", from: "department_find" |
| 341 | + select "(77777) RDSS-Research Data and Scholarship Services\u00A0", from: "department_find" |
| 342 | + # This is triggering the html5 element like it would normally if the page has focus |
| 343 | + page.find(:datalist_input, "department_find").execute_script("document.getElementById('department_find').dispatchEvent(new Event('input'))") |
| 344 | + expect(page).to have_field("request[departments][]", type: :hidden, with: "{\"code\":\"77777\",\"name\":\"RDSS-Research Data and Scholarship Services\"}") |
| 345 | + expect(page).to have_content("(77777) RDSS-Research Data and Scholarship Services").exactly(2).times |
| 346 | + |
| 347 | + click_on "Review and Submit" |
| 348 | + expect(page).to have_content("Take a moment to review your details and make any necessary edits before finalizing.") |
| 349 | + expect(page).to have_content("(77777) RDSS-Research Data and Scholarship Services").exactly(1).times |
| 350 | + |
| 351 | + fill_in :project_title, with: "No Duplicate Departments Project" |
| 352 | + fill_in :parent_folder, with: "abc_lab" |
| 353 | + fill_in :project_folder, with: "skeletor" |
| 354 | + fill_in :description, with: "An awesome project to show the wizard is magic" |
| 355 | + select "Research", from: "project_purpose" |
| 356 | + select_user(current_user, "data_sponsor", "request[data_sponsor]") |
| 357 | + select_user(current_user, "data_manager", "request[data_manager]") |
| 358 | + |
| 359 | + click_on "Submit" |
| 360 | + expect(page).to have_content("Your new project request is submitted") |
| 361 | + |
| 362 | + visit "requests/#{Request.last.id}" |
| 363 | + expect(page).to have_content("No Duplicate Departments Project") |
| 364 | + expect(page).to have_content("RDSS-Research Data and Scholarship Services").exactly(1).times |
| 365 | + end |
| 366 | + |
334 | 367 | it "allows for save and exit" do |
335 | 368 | sign_in current_user |
336 | 369 | visit "/" |
|
0 commit comments