replyr 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +41 -5
- data/lib/generators/replyr/templates/mailman_server +3 -3
- data/lib/generators/replyr/templates/replyr.rb.erb +12 -3
- data/lib/replyr.rb +31 -4
- data/lib/replyr/address_builder.rb +69 -0
- data/lib/replyr/bounce_address.rb +52 -0
- data/lib/replyr/config.rb +18 -5
- data/lib/replyr/{reply_email.rb → email.rb} +20 -4
- data/lib/replyr/engine.rb +1 -0
- data/lib/replyr/handle_bounce.rb +35 -0
- data/lib/replyr/reply_address.rb +7 -68
- data/lib/replyr/version.rb +1 -1
- data/test/dummy/app/models/user.rb +5 -0
- data/test/dummy/config/initializers/replyr.rb +2 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +16508 -0
- data/test/replyr/bounce_address_test.rb +91 -0
- data/test/replyr/email_test.rb +93 -0
- data/test/replyr/emails/bounce_422.eml +98 -0
- data/test/replyr/emails/bounce_530.eml +96 -0
- data/test/replyr/handle_bounce_test.rb +33 -0
- data/test/replyr/handle_reply_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +11 -4
- data/test/replyr/reply_email_test.rb +0 -51
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
setup_database
|
4
|
+
|
5
|
+
describe Replyr::BounceAddress do
|
6
|
+
describe '#new' do
|
7
|
+
it 'returns new address' do
|
8
|
+
@user = User.create
|
9
|
+
|
10
|
+
address = Replyr::BounceAddress.new(@user)
|
11
|
+
assert_kind_of Replyr::BounceAddress, address
|
12
|
+
assert_equal @user, address.model
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#new_from_address' do
|
18
|
+
it 'returns new instance if address is valid' do
|
19
|
+
user = User.create
|
20
|
+
correct_address = Replyr::BounceAddress.new(user).address
|
21
|
+
address = Replyr::BounceAddress.new_from_address(correct_address)
|
22
|
+
assert_kind_of Replyr::BounceAddress, address
|
23
|
+
assert_equal user.id, address.model.id
|
24
|
+
assert_equal user.class.name, address.model.class.name
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'return nil if email address is malformed (no reply email)' do
|
28
|
+
assert_equal nil, Replyr::BounceAddress.new_from_address("malformed@example.com")
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns nil if addreess is invalid' do
|
32
|
+
assert_equal nil, Replyr::BounceAddress.new_from_address("reply-comment-1-1-wrongtoken@example.com")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#token_valid?' do
|
37
|
+
before do
|
38
|
+
@address = Replyr::BounceAddress.new(User.create)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'return true if the passed token is valid' do
|
42
|
+
assert_equal true, @address.token_valid?(@address.token)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'return false if the passed token is valid' do
|
46
|
+
assert_equal false, @address.token_valid?("wrong_token")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#ensure_valid_token!' do
|
51
|
+
before do
|
52
|
+
@address = Replyr::BounceAddress.new(User.create)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'throws exception if token is invalid' do
|
56
|
+
assert_raises RuntimeError do
|
57
|
+
@address.ensure_valid_token!("wrong_token")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'throws exception if token is invalid' do
|
62
|
+
assert_equal nil, @address.ensure_valid_token!(@address.token)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#token' do
|
67
|
+
before do
|
68
|
+
@user1 = User.create
|
69
|
+
@user2 = User.create
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns an auth token' do
|
73
|
+
address = Replyr::BounceAddress.new(@user1)
|
74
|
+
assert_kind_of String, address.token
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'return the same auth token for same arguments' do
|
78
|
+
address1 = Replyr::BounceAddress.new(@user2)
|
79
|
+
address2 = Replyr::BounceAddress.new(@user2)
|
80
|
+
assert_equal address1.token, address2.token
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'return a different auth token for different user' do
|
84
|
+
address1 = Replyr::BounceAddress.new(@user1)
|
85
|
+
address2 = Replyr::BounceAddress.new(@user2)
|
86
|
+
refute_equal address1.token, address2.token
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require 'mail'
|
4
|
+
|
5
|
+
describe Replyr::Email do
|
6
|
+
describe "#new" do
|
7
|
+
it 'parses plain message object correctly' do
|
8
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/reply_plain.eml'))
|
9
|
+
assert_equal "wursttheke@me.com", email.from
|
10
|
+
assert_equal "Das ist wunderschön", email.stripped_body
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'parses multipart message object correctly' do
|
14
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/reply_multipart.eml'))
|
15
|
+
assert_equal "wursttheke@me.com", email.from
|
16
|
+
assert_equal "Das ist wunderschön", email.stripped_body
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'removes signature from message object' do
|
20
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/reply_plain_signature.eml'))
|
21
|
+
assert_equal "wursttheke@me.com", email.from
|
22
|
+
assert_equal "Das ist wunderschön", email.stripped_body
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#is_bounce_email?' do
|
28
|
+
it 'returns true for a bounce mail (failed)' do
|
29
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/bounce_530.eml'))
|
30
|
+
assert_equal true, email.is_bounce_email?
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns false for a bounce mail (temporary failure)' do
|
34
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/bounce_422.eml'))
|
35
|
+
assert_equal false, email.is_bounce_email?
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns false for a normal mail' do
|
39
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/reply_plain.eml'))
|
40
|
+
assert_equal false, email.is_bounce_email?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#failed_permanently?' do
|
45
|
+
it 'returns true for a bounce mail of type 5.x.x' do
|
46
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/bounce_530.eml'))
|
47
|
+
assert_equal true, email.failed_permanently?
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns true for a bounce mail of type 4.x.x' do
|
51
|
+
email = Replyr::Email.new(Mail.read('test/replyr/emails/bounce_422.eml'))
|
52
|
+
assert_equal false, email.failed_permanently?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#process' do
|
57
|
+
it 'returns false if mail is invalid' do
|
58
|
+
mail = Mail.read('test/replyr/emails/reply_plain.eml')
|
59
|
+
email = Replyr::Email.new(mail)
|
60
|
+
assert_equal false, email.process
|
61
|
+
end
|
62
|
+
|
63
|
+
it "processes reply mail if it's valid and return true" do
|
64
|
+
address = Replyr::ReplyAddress.new(Comment.create, User.create).address
|
65
|
+
mail = Mail.read('test/replyr/emails/reply_plain.eml')
|
66
|
+
mail.to = address # set correct address
|
67
|
+
email = Replyr::Email.new(mail)
|
68
|
+
|
69
|
+
assert true, email.is_reply_email?
|
70
|
+
|
71
|
+
comment_count = Comment.count
|
72
|
+
assert_equal true, email.process
|
73
|
+
assert_equal comment_count + 1, Comment.count
|
74
|
+
end
|
75
|
+
|
76
|
+
it "processes bounce mail if it's valid and return true" do
|
77
|
+
user = User.create(email: "test@example.com")
|
78
|
+
address = Replyr::BounceAddress.new(user).address
|
79
|
+
mail = Mail.read('test/replyr/emails/bounce_530.eml')
|
80
|
+
mail.to = address # set correct address
|
81
|
+
email = Replyr::Email.new(mail)
|
82
|
+
|
83
|
+
assert_equal true, email.is_bounce_email?
|
84
|
+
assert_equal false, user.email_invalid?
|
85
|
+
assert_equal true, email.process
|
86
|
+
assert_equal true, user.reload.email_invalid?
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
Return-Path: <mail_dump@ns1.sssssss.net.au>
|
2
|
+
Received: from acomputer ([unix socket])
|
3
|
+
by imap01.sssssss.net (Cyrus) with LMTPA;
|
4
|
+
Wed, 16 Jan 2008 13:51:42 -0800
|
5
|
+
X-Sieve: CMU Sieve 2.2
|
6
|
+
Received: from smtp.sssssss.org (unknown [198.0.0.92])
|
7
|
+
by imap01.sssssss.net (Postfix) with ESMTP id BFE6477FAE
|
8
|
+
for <aaaa@sssssss.net>; Wed, 16 Jan 2008 13:51:40 -0800 (PST)
|
9
|
+
Received: from ns1.sssssss.net.au (ns1.sssssss.net.au [202.0.0.246])
|
10
|
+
by smtp.sssssss.org (Postfix) with ESMTP id 96E5C6C6830
|
11
|
+
for <aaaa@sssssss.net>; Wed, 16 Jan 2008 11:08:14 -0800 (PST)
|
12
|
+
Received: from ns1.sssssss.net.au (unknown [127.0.0.1])
|
13
|
+
by ns1.sssssss.net.au (Postfix) with ESMTP id E1BCEF227
|
14
|
+
for <aaaa@sssssss.net>; Thu, 17 Jan 2008 03:40:53 +1100 (EST)
|
15
|
+
Received: from ns1.sssssss.net.au (ns1.sssssss.net.au [202.0.0.246])
|
16
|
+
by localhost (FormatMessage) with SMTP id ceaa681bbcb6c7f6
|
17
|
+
for <jennifer@sss.sssssss.net.au>; Thu, 17 Jan 2008 03:40:53 +1100 (EST)
|
18
|
+
Received: from mail11.tppppp.com.au (unknown [203.0.0.161])
|
19
|
+
by ns1.sssssss.net.au (Postfix) with ESMTP id 7F2D2F225
|
20
|
+
for <jennifer@sss.sssssss.net.au>; Thu, 17 Jan 2008 03:40:52 +1100 (EST)
|
21
|
+
Received: from localhost (localhost)
|
22
|
+
by mail11.tppppp.com.au (envelope-from MAILER-DAEMON) (8.14.2/8.14.2) id m0GFZ1c3009410;
|
23
|
+
Thu, 17 Jan 2008 03:40:52 +1100
|
24
|
+
Date: Thu, 17 Jan 2008 03:40:52 +1100
|
25
|
+
From: Mail Delivery Subsystem <MAILER-DAEMON@tppppp.com.au>
|
26
|
+
Message-Id: <200801161640.m0GFZ1c3009410@mail11.ttttt.com.au>
|
27
|
+
To: <jennifer@sss.sssssss.net.au>
|
28
|
+
MIME-Version: 1.0
|
29
|
+
Content-Type: multipart/report; report-type=delivery-status;
|
30
|
+
boundary="m0GFZ1c3009410.1200501652/mail11.ttttt.com.au"
|
31
|
+
Subject: Warning: could not send message for past 8 hours
|
32
|
+
Auto-Submitted: auto-generated (warning-timeout)
|
33
|
+
Resent-Date: Thu, 17 Jan 2008 03:40:53 +1100 (EST)
|
34
|
+
Resent-From: <mail_dump@ns1.sssssss.net.au>
|
35
|
+
Resent-To: <mikel@sssssss.net>
|
36
|
+
Resent-Message-ID: <ceaa681bbcb6c7f6.1200501653@sssssss.net.au>
|
37
|
+
X-Spam-Status: No
|
38
|
+
|
39
|
+
|
40
|
+
--m0GFZ1c3009410.1200501652/mail11.ttttt.com.au
|
41
|
+
Content-Type: text/plain
|
42
|
+
|
43
|
+
**********************************************
|
44
|
+
** THIS IS A WARNING MESSAGE ONLY **
|
45
|
+
** YOU DO NOT NEED TO RESEND YOUR MESSAGE **
|
46
|
+
**********************************************
|
47
|
+
|
48
|
+
The original message was received at Wed, 16 Jan 2008 19:38:07 +1100
|
49
|
+
from 60-0-0-61.static.tppppp.com.au [60.0.0.61]
|
50
|
+
|
51
|
+
This message was generated by mail11.tppppp.com.au
|
52
|
+
|
53
|
+
----- Transcript of session follows -----
|
54
|
+
.... while talking to mail.oooooooo.com.au.:
|
55
|
+
>>> DATA
|
56
|
+
<<< 452 4.2.2 <fraser@oooooooo.com.au>... Mailbox full
|
57
|
+
<fraser@oooooooo.com.au>... Deferred: 452 4.2.2 <fraser@oooooooo.com.au>... Mailbox full
|
58
|
+
<<< 503 5.0.0 Need RCPT (recipient)
|
59
|
+
Warning: message still undelivered after 8 hours
|
60
|
+
Will keep trying until message is 5 days old
|
61
|
+
|
62
|
+
--
|
63
|
+
This message has been scanned for viruses and
|
64
|
+
dangerous content by MailScanner, and is
|
65
|
+
believed to be clean.
|
66
|
+
|
67
|
+
|
68
|
+
--m0GFZ1c3009410.1200501652/mail11.ttttt.com.au
|
69
|
+
Content-Type: message/delivery-status
|
70
|
+
|
71
|
+
Reporting-MTA: dns; mail11.ttttt.com.au
|
72
|
+
Arrival-Date: Wed, 16 Jan 2008 19:38:07 +1100
|
73
|
+
|
74
|
+
Final-Recipient: RFC822; fraser@oooooooo.com.au
|
75
|
+
Action: delayed
|
76
|
+
Status: 4.2.2
|
77
|
+
Remote-MTA: DNS; mail.oooooooo.com.au
|
78
|
+
Diagnostic-Code: SMTP; 452 4.2.2 <fraser@oooooooo.com.au>... Mailbox full
|
79
|
+
Last-Attempt-Date: Thu, 17 Jan 2008 03:40:52 +1100
|
80
|
+
|
81
|
+
--m0GFZ1c3009410.1200501652/mail11.ttttt.com.au
|
82
|
+
Content-Type: text/rfc822-headers
|
83
|
+
|
84
|
+
Return-Path: <jennifer@sss.sssssss.net.au>
|
85
|
+
Received: from k1s2yo86 (60-0-0-61.static.tppppp.com.au [60.0.0.61])
|
86
|
+
by mail11.tppppp.com.au (envelope-from jennifer@sss.sssssss.net.au) (8.14.2/8.14.2) with ESMTP id m0G8c0fR020461
|
87
|
+
for <fraser@oooooooo.com.au>; Wed, 16 Jan 2008 19:38:07 +1100
|
88
|
+
Date: Wed, 16 Jan 2008 19:38:07 +1100
|
89
|
+
From: Sydney <jennifer@sss.sssssss.net.au>
|
90
|
+
Message-ID: <15655788.13.1200472642578.JavaMail.Administrator@mail.ttttt.com.au>
|
91
|
+
Subject: Wanted
|
92
|
+
MIME-Version: 1.0
|
93
|
+
Content-Type: multipart/mixed;
|
94
|
+
boundary="----=_Part_12_28168925.1200472642578"
|
95
|
+
X-Virus-Scanned: ClamAV 0.91.2/5484/Wed Jan 16 06:31:27 2008 on mail11.tppppp.com.au
|
96
|
+
X-Virus-Status: Clean
|
97
|
+
|
98
|
+
--m0GFZ1c3009410.1200501652/mail11.ttttt.com.au--
|
@@ -0,0 +1,96 @@
|
|
1
|
+
Return-Path: <MAILER-DAEMON@imap01.sssss.net>
|
2
|
+
Received: from acomputer ([unix socket])
|
3
|
+
by imap01.sssss.net (Cyrus) with LMTPA;
|
4
|
+
Sun, 23 Dec 2007 15:04:04 -0800
|
5
|
+
X-Sieve: CMU Sieve 2.2
|
6
|
+
Received: from smtp.sssss.org (unknown [198.0.0.92])
|
7
|
+
by imap01.sssss.net (Postfix) with ESMTP id E434877FB0
|
8
|
+
for <mikel@sssss.net>; Sun, 23 Dec 2007 15:04:03 -0800 (PST)
|
9
|
+
Received: from mail12.tttttt.com.au (mail12.tttttt.com.au [203.0.0.162])
|
10
|
+
by smtp.sssss.org (Postfix) with ESMTP id 53313B42B7
|
11
|
+
for <mikel@sssss.net>; Sun, 23 Dec 2007 15:03:54 -0800 (PST)
|
12
|
+
Received: from localhost (localhost)
|
13
|
+
by mail12.tttttt.com.au (envelope-from MAILER-DAEMON) (8.14.2/8.14.2) id lBNN3rDp003436;
|
14
|
+
Mon, 24 Dec 2007 10:03:53 +1100
|
15
|
+
Date: Mon, 24 Dec 2007 10:03:53 +1100
|
16
|
+
From: Mail Delivery Subsystem <MAILER-DAEMON@tttttt.com.au>
|
17
|
+
Message-Id: <200712232303.lBNN3rDp003436@mail12.rrrr.com.au>
|
18
|
+
To: <mikel@sssss.net>
|
19
|
+
MIME-Version: 1.0
|
20
|
+
Content-Type: multipart/report; report-type=delivery-status;
|
21
|
+
boundary="lBNN3rDp003436.1198451033/mail12.rrrr.com.au"
|
22
|
+
Subject: Returned mail: see transcript for details
|
23
|
+
Auto-Submitted: auto-generated (failure)
|
24
|
+
X-Spam-Status: No
|
25
|
+
|
26
|
+
This is a MIME-encapsulated message
|
27
|
+
|
28
|
+
--lBNN3rDp003436.1198451033/mail12.rrrr.com.au
|
29
|
+
|
30
|
+
The original message was received at Mon, 24 Dec 2007 10:03:47 +1100
|
31
|
+
from 60-0-0-146.static.tttttt.com.au [60.0.0.146]
|
32
|
+
|
33
|
+
This message was generated by mail12.tttttt.com.au
|
34
|
+
|
35
|
+
----- The following addresses had permanent fatal errors -----
|
36
|
+
<edwin@zzzzzzz.com>
|
37
|
+
(reason: 553 5.3.0 <edwin@zzzzzzz.com>... Unknown E-Mail Address)
|
38
|
+
|
39
|
+
----- Transcript of session follows -----
|
40
|
+
... while talking to mail.zzzzzz.com.:
|
41
|
+
>>> DATA
|
42
|
+
<<< 553 5.3.0 <edwin@zzzzzzz.com>... Unknown E-Mail Address
|
43
|
+
550 5.1.1 <edwin@zzzzzzz.com>... User unknown
|
44
|
+
<<< 503 5.0.0 Need RCPT (recipient)
|
45
|
+
|
46
|
+
--
|
47
|
+
This message has been scanned for viruses and
|
48
|
+
dangerous content by MailScanner, and is
|
49
|
+
believed to be clean.
|
50
|
+
|
51
|
+
|
52
|
+
--lBNN3rDp003436.1198451033/mail12.rrrr.com.au
|
53
|
+
Content-Type: message/delivery-status
|
54
|
+
|
55
|
+
Reporting-MTA: dns; mail12.rrrr.com.au
|
56
|
+
Received-From-MTA: DNS; 60-0-0-146.static.tttttt.com.au
|
57
|
+
Arrival-Date: Mon, 24 Dec 2007 10:03:47 +1100
|
58
|
+
|
59
|
+
Final-Recipient: RFC822; edwin@zzzzzzz.com
|
60
|
+
Action: failed
|
61
|
+
Status: 5.3.0
|
62
|
+
Remote-MTA: DNS; mail.zzzzzz.com
|
63
|
+
Diagnostic-Code: SMTP; 553 5.3.0 <edwin@zzzzzzz.com>... Unknown E-Mail Address
|
64
|
+
Last-Attempt-Date: Mon, 24 Dec 2007 10:03:53 +1100
|
65
|
+
|
66
|
+
--lBNN3rDp003436.1198451033/mail12.rrrr.com.au
|
67
|
+
Content-Type: text/rfc822-headers
|
68
|
+
|
69
|
+
Return-Path: <mikel@sssss.net>
|
70
|
+
Received: from [192.168.0.3] (60-0-0-146.static.tttttt.com.au [60.0.0.146])
|
71
|
+
by mail12.tttttt.com.au (envelope-from mikel@sssss.net) (8.14.2/8.14.2) with ESMTP id lBNN3jDq002941
|
72
|
+
for <edwin@zzzzzzz.com>; Mon, 24 Dec 2007 10:03:47 +1100
|
73
|
+
Resent-Date: Mon, 24 Dec 2007 10:03:47 +1100
|
74
|
+
Date: Mon, 24 Dec 2007 10:03:47 +1100
|
75
|
+
Resent-Message-Id: <200712232303.lBNN3jDq002941@mail12.rrrr.com.au>
|
76
|
+
Message-Id: <200712232303.lBNN3jDq002941@mail12.rrrr.com.au>
|
77
|
+
Mime-Version: 1.0
|
78
|
+
Content-Type: multipart/report;
|
79
|
+
report-type=delivery-status;
|
80
|
+
boundary=80874BE0-2DFF-4BCB-8AA1-A00E17ACA2EA
|
81
|
+
Received: from murder ([unix socket]) by imap01.sssss.net (Cyrus v2.2.12-Invoca-RPM-2.2.12-6.fc4) with LMTPA; Sun, 23 Dec 2007 12:59:14 -0800
|
82
|
+
Received: from smtp.sssss.org (unknown [198.0.0.92]) by imap01.sssss.net (Postfix) with ESMTP id 0AC9F77EDD for <mikel@sssss.net>; Sun, 23 Dec 2007 12:59:14 -0800 (PST)
|
83
|
+
Received: from ns1.sssss.net.au (ns1.sssss.net.au [202.0.0.246]) by smtp.sssss.org (Postfix) with ESMTP id 6FC83B42B4 for <mikel@sssss.net>; Sun, 23 Dec 2007 12:59:09 -0800 (PST)
|
84
|
+
Received: from unicom (unknown [85.0.0.121]) by ns1.sssss.net.au (Postfix) with ESMTP id 85ED5F1F7 for <webmaster@dianetics.org.au>; Mon, 24 Dec 2007 07:59:02 +1100 (EST)
|
85
|
+
Received: from [85.0.0.121] by mail.zzzzzz.com; , 23 Dec 2007 12:57:34 -0800
|
86
|
+
X-Mailer: Apple Mail (2.753)
|
87
|
+
From: postoffice
|
88
|
+
Subject: Returned mail: User unknown
|
89
|
+
Resent-From: mikel@sssss.net
|
90
|
+
Auto-Submitted: auto-generated (failure)
|
91
|
+
To: "Merrill" <edwin@zzzzzzz.com>
|
92
|
+
X-Virus-Scanned: ClamAV 0.91.2/5229/Mon Dec 24 07:36:55 2007 on mail12.tttttt.com.au
|
93
|
+
X-Virus-Status: Clean
|
94
|
+
|
95
|
+
--lBNN3rDp003436.1198451033/mail12.rrrr.com.au--
|
96
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
setup_database
|
4
|
+
|
5
|
+
describe Replyr::HandleBounce do
|
6
|
+
describe '#bounce_address_object' do
|
7
|
+
it 'returns bounce return_path address object' do
|
8
|
+
@user = User.create
|
9
|
+
address = @user.bounce_address_object
|
10
|
+
assert_kind_of Replyr::BounceAddress, address
|
11
|
+
assert_equal @user, address.model
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#bounce_address' do
|
16
|
+
it 'returns bounce return_path address string' do
|
17
|
+
@user = User.create
|
18
|
+
address = @user.bounce_address
|
19
|
+
assert_kind_of String, address
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#handle_bounce' do
|
24
|
+
it 'receives the passed reply and calls block' do
|
25
|
+
user = User.create(email: "test@example.com")
|
26
|
+
assert_equal false, user.email_invalid?
|
27
|
+
user.handle_bounce(user.email)
|
28
|
+
new_count = Comment.count
|
29
|
+
assert_equal true, user.email_invalid?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -16,7 +16,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
16
16
|
|
17
17
|
def setup_database
|
18
18
|
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS users")
|
19
|
-
ActiveRecord::Base.connection.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")
|
19
|
+
ActiveRecord::Base.connection.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT, email_invalid BOOLEAN)")
|
20
20
|
|
21
21
|
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS comments")
|
22
22
|
ActiveRecord::Base.connection.execute("CREATE TABLE comments (id INTEGER PRIMARY KEY, body TEXT, user_id INTEGER)")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: replyr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Wüllner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mailman
|
@@ -108,11 +108,14 @@ files:
|
|
108
108
|
- lib/generators/replyr/templates/mailman_server
|
109
109
|
- lib/generators/replyr/templates/replyr.rb.erb
|
110
110
|
- lib/mailman_monkey_patch.rb
|
111
|
+
- lib/replyr/address_builder.rb
|
112
|
+
- lib/replyr/bounce_address.rb
|
111
113
|
- lib/replyr/config.rb
|
114
|
+
- lib/replyr/email.rb
|
112
115
|
- lib/replyr/engine.rb
|
116
|
+
- lib/replyr/handle_bounce.rb
|
113
117
|
- lib/replyr/handle_reply.rb
|
114
118
|
- lib/replyr/reply_address.rb
|
115
|
-
- lib/replyr/reply_email.rb
|
116
119
|
- lib/replyr/version.rb
|
117
120
|
- lib/replyr.rb
|
118
121
|
- lib/tasks/replyr_tasks.rake
|
@@ -204,13 +207,17 @@ files:
|
|
204
207
|
- test/email_reply_parser/emails/email_sent_from_my_not_signature.txt
|
205
208
|
- test/email_reply_parser/emails/email_was_showing_as_nothing_visible.txt
|
206
209
|
- test/email_reply_parser/emails/new_content/email_1_2.txt
|
210
|
+
- test/replyr/bounce_address_test.rb
|
211
|
+
- test/replyr/email_test.rb
|
212
|
+
- test/replyr/emails/bounce_422.eml
|
213
|
+
- test/replyr/emails/bounce_530.eml
|
207
214
|
- test/replyr/emails/reply_multipart.eml
|
208
215
|
- test/replyr/emails/reply_plain.eml
|
209
216
|
- test/replyr/emails/reply_plain_signature.eml
|
210
217
|
- test/replyr/emails/reply_with_attachment.eml
|
218
|
+
- test/replyr/handle_bounce_test.rb
|
211
219
|
- test/replyr/handle_reply_test.rb
|
212
220
|
- test/replyr/reply_address_test.rb
|
213
|
-
- test/replyr/reply_email_test.rb
|
214
221
|
- test/replyr_test.rb
|
215
222
|
- test/test_helper.rb
|
216
223
|
- CHANGELOG.md
|