about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-06-14 00:10:52 +0000
committerEric Wong <e@80x24.org>2017-06-15 23:13:00 +0000
commitef3ca9b80fcb464d851c2f8d87f3f02f4f70986d (patch)
tree905052112686dec08eea7d4b6d2c87216e36fe0b /t
parent92afb41e15dfdcda291b432173bd49ddfc49614a (diff)
downloadpublic-inbox-ef3ca9b80fcb464d851c2f8d87f3f02f4f70986d.tar.gz
This allows us to support centralized mailing lists (which suck,
but better than no mailing list at all).
Diffstat (limited to 't')
-rw-r--r--t/reply.t67
-rw-r--r--t/view.t12
2 files changed, 67 insertions, 12 deletions
diff --git a/t/reply.t b/t/reply.t
new file mode 100644
index 00000000..640069cb
--- /dev/null
+++ b/t/reply.t
@@ -0,0 +1,67 @@
+# Copyright (C) 2017 all contributors <meta@public-inbox.org>
+# License: AGPL-3+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use strict;
+use warnings;
+use Test::More;
+use Email::MIME;
+use_ok 'PublicInbox::Reply';
+
+my @q = (
+        'foo@bar', 'foo@bar',
+        'a b', "'a b'",
+        "a'b", "'a'\\''b'",
+);
+
+while (@q) {
+        my $input = shift @q;
+        my $expect = shift @q;
+        my $res = PublicInbox::Reply::squote_maybe($input);
+        is($res, $expect, "quote $input => $res");
+}
+
+my $mime = Email::MIME->new(<<'EOF');
+From: from <from@example.com>
+To: to <to@example.com>
+Cc: cc@example.com
+Message-Id: <blah@example.com>
+Subject: hihi
+
+EOF
+
+my $hdr = $mime->header_obj;
+my $ibx = { -primary_address => 'primary@example.com' };
+
+my ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+my $exp = [
+    '--in-reply-to=blah@example.com',
+    '--to=from@example.com',
+    '--cc=cc@example.com',
+    '--cc=to@example.com'
+];
+
+is_deeply($arg, $exp, 'default reply is to :all');
+$ibx->{replyto} = ':all';
+($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+is_deeply($arg, $exp, '":all" also works');
+
+$exp = [ '--in-reply-to=blah@example.com', '--to=primary@example.com' ];
+$ibx->{replyto} = ':list';
+($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+is_deeply($arg, $exp, '":list" works for centralized lists');
+
+$exp = [
+         '--in-reply-to=blah@example.com',
+         '--to=primary@example.com',
+         '--cc=cc@example.com',
+         '--cc=to@example.com'
+];
+$ibx->{replyto} = ':list,Cc,To';
+($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+is_deeply($arg, $exp, '":list,Cc,To" works for kinda centralized lists');
+
+$ibx->{replyto} = 'new@example.com';
+($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+$exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com' ];
+is_deeply($arg, $exp, 'explicit address works, too');
+
+done_testing();
diff --git a/t/view.t b/t/view.t
index abd00018..1f4ed937 100644
--- a/t/view.t
+++ b/t/view.t
@@ -7,18 +7,6 @@ use Email::MIME;
 use Plack::Util;
 use_ok 'PublicInbox::View';
 
-my @q = (
-        'foo@bar', 'foo@bar',
-        'a b', "'a b'",
-        "a'b", "'a'\\''b'",
-);
-while (@q) {
-        my $input = shift @q;
-        my $expect = shift @q;
-        my $res = PublicInbox::Reply::squote_maybe($input);
-        is($res, $expect, "quote $input => $res");
-}
-
 # FIXME: make this test less fragile
 my $ctx = {
         env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'http' },