|
82 | 82 | expect(msg.mailing_lists).to include(hackers_list) |
83 | 83 | end |
84 | 84 |
|
| 85 | + it "resolves list from alternate email in CC" do |
| 86 | + hackers_list.update!(alternate_emails: ["pgsql-hackers@postgresql.org"]) |
| 87 | + state = ImapSyncState.for_label("INBOX") |
| 88 | + allow(imap_client).to receive(:connect!).and_return(true) |
| 89 | + allow(imap_client).to receive(:disconnect!).and_return(true) |
| 90 | + expect(imap_client).to receive(:uids_after).with(0).and_return([203]) |
| 91 | + raw = <<~MAIL |
| 92 | + From: Test <test@example.com> |
| 93 | + To: peter@eisentraut.org |
| 94 | + CC: pgsql-hackers@postgresql.org |
| 95 | + Subject: Re: SQL Property Graph Queries |
| 96 | + Date: Fri, 1 Jan 2021 12:00:00 +0000 |
| 97 | + Message-ID: <uid-203@example.com> |
| 98 | + MIME-Version: 1.0 |
| 99 | + Content-Type: text/plain; charset=UTF-8 |
| 100 | +
|
| 101 | + Body |
| 102 | + MAIL |
| 103 | + expect(imap_client).to receive(:uid_fetch_rfc822).with(203).and_return(raw) |
| 104 | + expect(imap_client).to receive(:mark_seen).with(203) |
| 105 | + expect(imap_client).to receive(:idle_once).and_return(:timeout) |
| 106 | + allow(imap_client).to receive(:uids_after).with(203).and_return([]) |
| 107 | + |
| 108 | + runner = described_class.new(client: imap_client, label: "INBOX") |
| 109 | + runner.run(max_cycles: 1, idle_timeout: 1) |
| 110 | + |
| 111 | + msg = Message.find_by(message_id: "uid-203@example.com") |
| 112 | + expect(msg).to be_present |
| 113 | + expect(msg.mailing_lists).to include(hackers_list) |
| 114 | + end |
| 115 | + |
85 | 116 | it "skips message when no list can be resolved" do |
86 | 117 | state = ImapSyncState.for_label("INBOX") |
87 | 118 | allow(imap_client).to receive(:connect!).and_return(true) |
|
0 commit comments