|
218 | 218 | describe "#sync_status" do |
219 | 219 | subject(:sync_status) { vaccination_record.sync_status } |
220 | 220 |
|
| 221 | + let(:vaccination_record) do |
| 222 | + create(:vaccination_record, outcome:, programme:, session:) |
| 223 | + end |
| 224 | + |
221 | 225 | before { Flipper.enable(:imms_api_sync_job, programme) } |
222 | 226 |
|
223 | 227 | context "when patient has no NHS number" do |
|
607 | 611 | it { should be false } |
608 | 612 | end |
609 | 613 | end |
| 614 | + |
| 615 | + describe "#changes_need_to_be_synced_to_nhs_immunisations_api?" do |
| 616 | + subject do |
| 617 | + vaccination_record.changes_need_to_be_synced_to_nhs_immunisations_api? |
| 618 | + end |
| 619 | + |
| 620 | + let(:vaccination_record) do |
| 621 | + create(:vaccination_record, programme:, session:) |
| 622 | + end |
| 623 | + |
| 624 | + context "when no attributes have changed" do |
| 625 | + it { should be false } |
| 626 | + end |
| 627 | + |
| 628 | + context "when a FHIR content field changes" do |
| 629 | + before { vaccination_record.batch_number = "NEWBATCH" } |
| 630 | + |
| 631 | + it { should be true } |
| 632 | + end |
| 633 | + |
| 634 | + context "when outcome changes" do |
| 635 | + before { vaccination_record.outcome = :refused } |
| 636 | + |
| 637 | + it { should be true } |
| 638 | + end |
| 639 | + |
| 640 | + context "when notify_parents changes" do |
| 641 | + before { vaccination_record.notify_parents = false } |
| 642 | + |
| 643 | + it { should be true } |
| 644 | + end |
| 645 | + |
| 646 | + context "when discarded_at changes" do |
| 647 | + before { vaccination_record.discarded_at = Time.current } |
| 648 | + |
| 649 | + it { should be true } |
| 650 | + end |
| 651 | + |
| 652 | + context "when only notes change" do |
| 653 | + before { vaccination_record.notes = "Some new note" } |
| 654 | + |
| 655 | + it { should be false } |
| 656 | + end |
| 657 | + |
| 658 | + context "when only protocol changes" do |
| 659 | + before { vaccination_record.protocol = :psd } |
| 660 | + |
| 661 | + it { should be false } |
| 662 | + end |
| 663 | + |
| 664 | + context "when only nhs_immunisations_api_etag changes" do |
| 665 | + before { vaccination_record.nhs_immunisations_api_etag = "2" } |
| 666 | + |
| 667 | + it { should be false } |
| 668 | + end |
| 669 | + |
| 670 | + context "when only nhs_immunisations_api_sync_pending_at changes" do |
| 671 | + before do |
| 672 | + vaccination_record.nhs_immunisations_api_sync_pending_at = Time.current |
| 673 | + end |
| 674 | + |
| 675 | + it { should be false } |
| 676 | + end |
| 677 | + |
| 678 | + context "when only nhs_immunisations_api_synced_at changes" do |
| 679 | + before do |
| 680 | + vaccination_record.nhs_immunisations_api_synced_at = Time.current |
| 681 | + end |
| 682 | + |
| 683 | + it { should be false } |
| 684 | + end |
| 685 | + |
| 686 | + context "when only nhs_immunisations_api_id changes" do |
| 687 | + before { vaccination_record.nhs_immunisations_api_id = SecureRandom.uuid } |
| 688 | + |
| 689 | + it { should be false } |
| 690 | + end |
| 691 | + end |
610 | 692 | end |
0 commit comments