|
681 | 681 | end |
682 | 682 | end |
683 | 683 |
|
| 684 | + describe ".selected_intakes_for_first_deadline_reminder_notification" do |
| 685 | + let!(:az_intake_with_email_notifications_and_df_import) { |
| 686 | + create :state_file_az_intake, |
| 687 | + df_data_imported_at: 2.minutes.ago, |
| 688 | + email_address: '[email protected]', |
| 689 | + email_address_verified_at: 5.minutes.ago, |
| 690 | + email_notification_opt_in: 1 |
| 691 | + } |
| 692 | + let!(:az_intake_with_email_notifications_and_df_import_from_last_year) { |
| 693 | + create :state_file_az_intake, |
| 694 | + df_data_imported_at: 2.minutes.ago, |
| 695 | + email_address: '[email protected]', |
| 696 | + email_address_verified_at: 5.minutes.ago, |
| 697 | + email_notification_opt_in: 1, |
| 698 | + created_at: 1.year.ago |
| 699 | + } |
| 700 | + let!(:az_intake_with_email_notifications_without_df_import) { |
| 701 | + create :state_file_az_intake, |
| 702 | + df_data_imported_at: nil, |
| 703 | + email_address: '[email protected]', |
| 704 | + email_address_verified_at: 5.minutes.ago, |
| 705 | + email_notification_opt_in: 1, |
| 706 | + message_tracker: { "messages.state_file.welcome" => 2.days.ago.utc.strftime("%Y-%m-%d %H:%M:%S UTC") } |
| 707 | + } |
| 708 | + let!(:az_intake_with_recent_message) { |
| 709 | + create :state_file_az_intake, |
| 710 | + df_data_imported_at: nil, |
| 711 | + email_address: '[email protected]', |
| 712 | + email_address_verified_at: 5.minutes.ago, |
| 713 | + email_notification_opt_in: 1, |
| 714 | + message_tracker: { "messages.state_file.welcome" => DateTime.now.utc.strftime("%Y-%m-%d %H:%M:%S UTC") } |
| 715 | + } |
| 716 | + let!(:az_intake_with_text_notifications_and_df_import) { |
| 717 | + create :state_file_az_intake, |
| 718 | + df_data_imported_at: 2.minutes.ago, |
| 719 | + phone_number: "+15551115511", |
| 720 | + sms_notification_opt_in: 1, |
| 721 | + phone_number_verified_at: 5.minutes.ago |
| 722 | + } |
| 723 | + let!(:az_intake_with_unverified_text_notifications_and_df_import) { |
| 724 | + create :state_file_az_intake, |
| 725 | + df_data_imported_at: 2.minutes.ago, |
| 726 | + phone_number: "+15551115511", |
| 727 | + sms_notification_opt_in: "yes", |
| 728 | + email_address: '[email protected]', |
| 729 | + email_address_verified_at: 5.minutes.ago, |
| 730 | + email_notification_opt_in: "no" |
| 731 | + } |
| 732 | + let!(:az_intake_submitted) { |
| 733 | + create :state_file_az_intake, |
| 734 | + df_data_imported_at: 2.minutes.ago, |
| 735 | + email_address: '[email protected]', |
| 736 | + email_address_verified_at: 5.minutes.ago, |
| 737 | + email_notification_opt_in: 1 |
| 738 | + } |
| 739 | + let!(:efile_submission) { create :efile_submission, :for_state, data_source: az_intake_submitted } |
| 740 | + |
| 741 | + let!(:az_intake_has_disqualifying_df_data) { |
| 742 | + create :state_file_az_intake, |
| 743 | + filing_status: :married_filing_separately, |
| 744 | + email_address: "[email protected]", |
| 745 | + email_address_verified_at: 1.hour.ago, |
| 746 | + email_notification_opt_in: 1, |
| 747 | + df_data_imported_at: 2.minutes.ago |
| 748 | + } |
| 749 | + |
| 750 | + let!(:az_intake_submitted_ssn_duplicate) { |
| 751 | + create :state_file_az_intake, |
| 752 | + email_address: "[email protected]", |
| 753 | + email_address_verified_at: 1.hour.ago, |
| 754 | + email_notification_opt_in: 1, |
| 755 | + phone_number: nil, |
| 756 | + df_data_imported_at: 2.minutes.ago, |
| 757 | + hashed_ssn: "111443333" |
| 758 | + } |
| 759 | + let!(:az_intake_submitted_ssn_duplicate_1) { |
| 760 | + create :state_file_az_intake, |
| 761 | + email_address: "[email protected]", |
| 762 | + email_address_verified_at: 1.hour.ago, |
| 763 | + email_notification_opt_in: 1, |
| 764 | + phone_number: nil, |
| 765 | + df_data_imported_at: 2.minutes.ago, |
| 766 | + hashed_ssn: "111443333" |
| 767 | + } |
| 768 | + let!(:efile_submission_for_duplicate) { create :efile_submission, :for_state, data_source: az_intake_submitted_ssn_duplicate } |
| 769 | + |
| 770 | + before do |
| 771 | + allow(Flipper).to receive(:enabled?).and_call_original |
| 772 | + allow(Flipper).to receive(:enabled?).with(:prevent_duplicate_ssn_messaging).and_return(true) |
| 773 | + |
| 774 | + allow_any_instance_of(StateFileAzIntake).to receive(:should_be_sent_reminder?).and_return(true) |
| 775 | + end |
| 776 | + |
| 777 | + it "returns only current-year intakes without df data that have no other messages within the past 24 hours and have no disqualifying/duplicate-with-submission issues" do |
| 778 | + results = StateFileAzIntake.selected_intakes_for_first_deadline_reminder_notification |
| 779 | + |
| 780 | + expect(results).to match_array([az_intake_with_email_notifications_without_df_import]) |
| 781 | + end |
| 782 | + end |
| 783 | + |
| 784 | + |
684 | 785 | describe "#should_be_sent_reminder?" do |
685 | 786 | let(:message_tracker) { nil } |
686 | 787 | let(:intake) { create :state_file_az_intake, message_tracker: message_tracker } |
|
0 commit comments