|
661 | 661 | end |
662 | 662 | end |
663 | 663 |
|
664 | | - describe "should_be_in_immunisations_api?" do |
665 | | - subject(:should_be_in_immunisations_api) do |
666 | | - described_class.should_be_in_immunisations_api?(vaccination_record) |
667 | | - end |
668 | | - |
669 | | - context "when all conditions are met" do |
670 | | - it { should be true } |
671 | | - end |
672 | | - |
673 | | - context "when the vaccination record has been discarded" do |
674 | | - before { vaccination_record.discard! } |
675 | | - |
676 | | - it { should be false } |
677 | | - end |
678 | | - |
679 | | - context "when the vaccination record doesn't have the correct source" do |
680 | | - before do |
681 | | - allow(vaccination_record).to receive( |
682 | | - :correct_source_for_nhs_immunisations_api? |
683 | | - ).and_return(false) |
684 | | - end |
685 | | - |
686 | | - it { should be false } |
687 | | - end |
688 | | - |
689 | | - VaccinationRecord.defined_enums["outcome"].each_key do |outcome| |
690 | | - next if outcome == "administered" |
691 | | - |
692 | | - context "the vaccination record outcome is #{outcome}" do |
693 | | - let(:vaccination_record) do |
694 | | - create( |
695 | | - :vaccination_record, |
696 | | - outcome:, |
697 | | - patient:, |
698 | | - nhs_immunisations_api_synced_at:, |
699 | | - nhs_immunisations_api_id:, |
700 | | - nhs_immunisations_api_primary_source:, |
701 | | - nhs_immunisations_api_etag:, |
702 | | - nhs_immunisations_api_sync_pending_at: |
703 | | - ) |
704 | | - end |
705 | | - |
706 | | - it { should be false } |
707 | | - end |
708 | | - end |
709 | | - |
710 | | - context "when the patient has no NHS number" do |
711 | | - before { patient.update(nhs_number: nil) } |
712 | | - |
713 | | - it { should be true } |
714 | | - end |
715 | | - |
716 | | - context "when the patient has requested that their parents aren't notified" do |
717 | | - before do |
718 | | - create( |
719 | | - :consent, |
720 | | - :given, |
721 | | - :self_consent, |
722 | | - patient:, |
723 | | - programme:, |
724 | | - notify_parents_on_vaccination: false |
725 | | - ) |
726 | | - end |
727 | | - |
728 | | - let(:notify_parents) { false } |
729 | | - |
730 | | - it { should be false } |
731 | | - end |
732 | | - |
733 | | - context "when notify_parents is not set" do |
734 | | - let(:notify_parents) { nil } |
735 | | - |
736 | | - it { should be true } |
737 | | - end |
738 | | - |
739 | | - context "when the patient is invalidated" do |
740 | | - before { patient.update(invalidated_at: Time.current) } |
741 | | - |
742 | | - it { should be false } |
743 | | - end |
744 | | - |
745 | | - context "when the programme type is not enabled in the feature flag" do |
746 | | - let(:programme) { Programme.menacwy } |
747 | | - let(:vaccine) { programme.vaccines.first } |
748 | | - |
749 | | - before do |
750 | | - Flipper.disable(:imms_api_sync_job) |
751 | | - Flipper.enable(:imms_api_sync_job, Programme.hpv) |
752 | | - end |
753 | | - |
754 | | - it { should be false } |
755 | | - end |
756 | | - end |
757 | | - |
758 | 664 | describe "next_sync_action" do |
759 | 665 | subject(:next_sync_action) do |
760 | 666 | described_class.send(:next_sync_action, vaccination_record) |
|
791 | 697 | end |
792 | 698 |
|
793 | 699 | context "the vaccination record is already in-sync" do |
794 | | - let(:nhs_immunisations_api_synced_at) { 1.second.ago } |
795 | | - let(:nhs_immunisations_api_id) { Random.uuid } |
796 | | - let(:nhs_immunisations_api_primary_source) { true } |
797 | | - let(:nhs_immunisations_api_sync_pending_at) { 2.seconds.ago } |
| 700 | + before do |
| 701 | + vaccination_record.update_columns( |
| 702 | + nhs_immunisations_api_synced_at: 1.second.ago, |
| 703 | + nhs_immunisations_api_id: Random.uuid, |
| 704 | + nhs_immunisations_api_primary_source: true, |
| 705 | + nhs_immunisations_api_sync_pending_at: 2.seconds.ago |
| 706 | + ) |
| 707 | + end |
798 | 708 |
|
799 | 709 | it { should be_nil } |
800 | 710 | end |
|
0 commit comments