|
532 | 532 | # Setup for Git Repository |
533 | 533 | allow(Settings.repository).to receive(:type).and_return('git') |
534 | 534 |
|
535 | | - @assignment = create(:assignment) |
| 535 | + # Create assignment with group_max of 3 to accommodate test files |
| 536 | + @assignment = create(:assignment, assignment_properties_attributes: { group_max: 3 }) |
536 | 537 |
|
537 | 538 | # Create students corresponding to the file_good |
538 | 539 | @student_user_names = %w[c8shosta c5bennet] |
|
570 | 571 | expect(flash[:error]).not_to be_blank |
571 | 572 | expect(response).to redirect_to(action: 'index') |
572 | 573 | end |
| 574 | + |
| 575 | + it 'accepts groups within the maximum group size' do |
| 576 | + @assignment.update!(assignment_properties_attributes: { group_max: 2 }) |
| 577 | + # Students c8shosta and c5bennet are already created in the outer before block |
| 578 | + expect do |
| 579 | + post_as instructor, :upload, params: { |
| 580 | + course_id: course.id, |
| 581 | + assignment_id: @assignment.id, |
| 582 | + upload_file: fixture_file_upload('groups/form_good.csv', 'text/csv') |
| 583 | + } |
| 584 | + end.to have_enqueued_job(CreateGroupsJob) |
| 585 | + |
| 586 | + expect(response).to have_http_status(:found) |
| 587 | + expect(flash[:error]).to be_blank |
| 588 | + expect(response).to redirect_to(action: 'index') |
| 589 | + end |
| 590 | + |
| 591 | + it 'accepts single-member groups' do |
| 592 | + @assignment.update!(assignment_properties_attributes: { group_max: 1 }) |
| 593 | + create(:student, user: create(:end_user, user_name: 'solo_student')) |
| 594 | + |
| 595 | + csv_content = "group1,solo_student\n" |
| 596 | + file = Tempfile.new(['test_upload', '.csv']) |
| 597 | + file.write(csv_content) |
| 598 | + file.rewind |
| 599 | + |
| 600 | + expect do |
| 601 | + post_as instructor, :upload, params: { course_id: course.id, |
| 602 | + assignment_id: @assignment.id, |
| 603 | + upload_file: fixture_file_upload(file.path, 'text/csv') } |
| 604 | + end.to have_enqueued_job(CreateGroupsJob) |
| 605 | + |
| 606 | + file.close |
| 607 | + file.unlink |
| 608 | + |
| 609 | + expect(flash[:error]).to be_blank |
| 610 | + end |
| 611 | + |
| 612 | + context 'when uploading groups with inactive students' do |
| 613 | + before do |
| 614 | + @assignment.update!(assignment_properties_attributes: { group_max: 2 }) |
| 615 | + # Create an active student |
| 616 | + @active_student = create(:student, user: create(:end_user, user_name: 'active_student')) |
| 617 | + # Create an inactive student (hidden: true) |
| 618 | + @inactive_student = create(:student, hidden: true, user: create(:end_user, user_name: 'inactive_student')) |
| 619 | + end |
| 620 | + |
| 621 | + it 'allows importing groups with inactive students (ISSUE-7743)' do |
| 622 | + expect do |
| 623 | + post_as instructor, :upload, params: { |
| 624 | + course_id: course.id, |
| 625 | + assignment_id: @assignment.id, |
| 626 | + upload_file: fixture_file_upload('groups/form_with_inactive_students.csv', 'text/csv') |
| 627 | + } |
| 628 | + end.to have_enqueued_job(CreateGroupsJob) |
| 629 | + |
| 630 | + expect(response).to have_http_status(:found) |
| 631 | + expect(flash[:error]).to be_blank |
| 632 | + expect(response).to redirect_to(action: 'index') |
| 633 | + end |
| 634 | + end |
573 | 635 | end |
574 | 636 |
|
575 | 637 | describe '#create_groups_when_students_work_alone' do |
|
0 commit comments