|
579 | 579 |
|
580 | 580 | context 'when proforma_task has been exported from task' do |
581 | 581 | let(:proforma_task) { ProformaService::ConvertTaskToProformaTask.call(task:) } |
582 | | - let(:task) { create(:task, files: task_files, tests:, model_solutions:, title: 'title') } |
| 582 | + let!(:task) { create(:task, files: task_files, tests:, model_solutions:, title: 'title') } |
583 | 583 | let(:task_files) { build_list(:task_file, 1, :exportable, internal_description: 'original task file') } |
584 | 584 | let(:tests) { build_list(:test, 1, files: test_files) } |
585 | 585 | let(:test_files) { build_list(:task_file, 1, :exportable, internal_description: 'original test file') } |
|
596 | 596 | ))), |
597 | 597 | model_solutions: have(1).item.and(include(have_attributes( |
598 | 598 | id: model_solutions.first.id, |
599 | | - files: include(have_attributes(id: model_solutions.first.files.first.id)) |
| 599 | + files: have(1).item.and(include(have_attributes(id: model_solutions.first.files.first.id))) |
600 | 600 | ))), |
601 | 601 | tests: have(1).item.and(include(have_attributes( |
602 | 602 | id: tests.first.id, |
603 | | - files: include(have_attributes(id: tests.first.files.first.id)) |
| 603 | + files: have(1).item.and(include(have_attributes(id: tests.first.files.first.id))) |
604 | 604 | ))) |
605 | 605 | ) |
606 | 606 | end |
|
654 | 654 | task_file = proforma_task.files.first |
655 | 655 | test_file = proforma_task.tests.first.files.first |
656 | 656 | model_solution_file = proforma_task.model_solutions.first.files.first |
657 | | - proforma_task.files = [model_solution_file] |
658 | | - proforma_task.tests.first.files = [task_file] |
659 | | - proforma_task.model_solutions.first.files = [test_file] |
| 657 | + proforma_task.files = [test_file] |
| 658 | + proforma_task.tests = [ProformaXML::Test.new(title: 'replacement Test', id: 987_654_325, files: [model_solution_file])] |
| 659 | + proforma_task.model_solutions.first.files = [task_file] |
660 | 660 | end |
661 | 661 |
|
662 | 662 | it 'imports taskfiles correctly' do |
663 | 663 | expect(convert_to_task_service.files.first).to have_attributes( |
664 | | - id: model_solution_files.first.id, |
665 | | - internal_description: model_solution_files.first.internal_description |
| 664 | + id: test_files.first.id, |
| 665 | + internal_description: test_files.first.internal_description |
666 | 666 | ) |
667 | 667 | end |
668 | 668 |
|
669 | 669 | it 'imports testfiles correctly' do |
670 | 670 | expect(convert_to_task_service.tests.first.files.first).to have_attributes( |
671 | | - id: task_files.first.id, |
672 | | - internal_description: task_files.first.internal_description |
| 671 | + id: model_solution_files.first.id, |
| 672 | + internal_description: model_solution_files.first.internal_description |
673 | 673 | ) |
674 | 674 | end |
675 | 675 |
|
676 | 676 | it 'imports msfiles correctly' do |
677 | 677 | expect(convert_to_task_service.model_solutions.first.files.first).to have_attributes( |
678 | | - id: test_files.first.id, |
679 | | - internal_description: test_files.first.internal_description |
| 678 | + id: task_files.first.id, |
| 679 | + internal_description: task_files.first.internal_description |
680 | 680 | ) |
681 | 681 | end |
682 | 682 |
|
683 | 683 | it 'imports everything correctly' do |
684 | 684 | expect(convert_to_task_service).to have_attributes( |
685 | 685 | id: task.id, |
686 | 686 | files: have(1).item.and(include(have_attributes( |
687 | | - id: model_solution_files.first.id |
688 | | - ))), |
| 687 | + id: test_files.first.id |
| 688 | + ))), |
689 | 689 | model_solutions: have(1).item.and(include(have_attributes( |
690 | 690 | id: model_solutions.first.id, |
691 | | - files: include(have_attributes(id: test_files.first.id)) |
| 691 | + files: have(1).item.and(include(have_attributes(id: task_files.first.id))) |
692 | 692 | ))), |
693 | 693 | tests: have(1).item.and(include(have_attributes( |
694 | | - id: tests.first.id, |
695 | | - files: include(have_attributes(id: task_files.first.id)) |
| 694 | + id: 987_654_325, |
| 695 | + files: have(1).item.and(include(have_attributes(id: model_solution_files.first.id))) |
696 | 696 | ))) |
697 | 697 | ) |
698 | 698 | end |
|
705 | 705 |
|
706 | 706 | it 'imports taskfiles correctly' do |
707 | 707 | expect(task.files.first).to have_attributes( |
708 | | - id: model_solution_files.first.id, |
709 | | - internal_description: model_solution_files.first.internal_description |
| 708 | + id: test_files.first.id, |
| 709 | + internal_description: test_files.first.internal_description |
710 | 710 | ) |
711 | 711 | end |
712 | 712 |
|
713 | 713 | it 'imports testfiles correctly' do |
714 | 714 | expect(task.tests.first.files.first).to have_attributes( |
715 | | - id: task_files.first.id, |
716 | | - internal_description: task_files.first.internal_description |
| 715 | + id: model_solution_files.first.id, |
| 716 | + internal_description: model_solution_files.first.internal_description |
717 | 717 | ) |
718 | 718 | end |
719 | 719 |
|
720 | 720 | it 'imports msfiles correctly' do |
721 | 721 | expect(task.model_solutions.first.files.first).to have_attributes( |
722 | | - id: test_files.first.id, |
723 | | - internal_description: test_files.first.internal_description |
| 722 | + id: task_files.first.id, |
| 723 | + internal_description: task_files.first.internal_description |
724 | 724 | ) |
725 | 725 | end |
726 | 726 |
|
727 | 727 | it 'imports everything correctly' do |
728 | 728 | expect(task).to have_attributes( |
729 | 729 | id: task.id, |
730 | 730 | files: have(1).item.and(include(have_attributes( |
731 | | - id: model_solution_files.first.id |
732 | | - ))), |
| 731 | + id: test_files.first.id |
| 732 | + ))), |
733 | 733 | model_solutions: have(1).item.and(include(have_attributes( |
734 | 734 | id: model_solutions.first.id, |
735 | | - files: include(have_attributes(id: test_files.first.id)) |
| 735 | + files: have(1).item.and(include(have_attributes(id: task_files.first.id))) |
736 | 736 | ))), |
737 | 737 | tests: have(1).item.and(include(have_attributes( |
738 | | - id: tests.first.id, |
739 | | - files: include(have_attributes(id: task_files.first.id)) |
| 738 | + id: 987_654_325, |
| 739 | + files: have(1).item.and(include(have_attributes(id: model_solution_files.first.id))) |
740 | 740 | ))) |
741 | 741 | ) |
742 | 742 | end |
|
0 commit comments