aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-09-10 12:07:11 +0100
committerdakkar <dakkar@thenautilus.net>2016-09-10 12:07:11 +0100
commit7ca898a2ac3512baacd0e0864ce31531fc4f5bb9 (patch)
tree3a30a6c6bfe2590af1f4c15557fa90c4b640997c /t
parentfix RFC link for list headers (diff)
downloadSietima-7ca898a2ac3512baacd0e0864ce31531fc4f5bb9.tar.gz
Sietima-7ca898a2ac3512baacd0e0864ce31531fc4f5bb9.tar.bz2
Sietima-7ca898a2ac3512baacd0e0864ce31531fc4f5bb9.zip
role to add list command headers
it's a bit wonky, in that it expects either Email::Address objects (which get turned into mailto: URIs) or strings (which should be full URIs already), but we can make it better later
Diffstat (limited to 't')
-rw-r--r--t/tests/sietima/role/headers.t56
1 files changed, 56 insertions, 0 deletions
diff --git a/t/tests/sietima/role/headers.t b/t/tests/sietima/role/headers.t
new file mode 100644
index 0000000..7b3e4b7
--- /dev/null
+++ b/t/tests/sietima/role/headers.t
@@ -0,0 +1,56 @@
+#!perl
+use lib 't/lib';
+use Test::Sietima;
+
+package Sietima::Role::ForTesting {
+ use Moo::Role;
+ use Sietima::Policy;
+ use Sietima::Types qw(AddressFromStr);
+
+ around list_addresses => sub($orig,$self) {
+ return {
+ $self->$orig->%*,
+ test1 => AddressFromStr->coerce('name <someone@example.com>'),
+ 'test+2' => 'http://test.example.com',
+ };
+ };
+};
+
+my $s = make_sietima(
+ with_traits => ['Headers','WithAdmin','ForTesting'],
+ name => 'test-list',
+ admin => 'admin@example.com',
+ subscribers => [
+ 'one@users.example.com',
+ 'two@users.example.com',
+ ],
+);
+
+subtest 'list headers should be added' => sub {
+ test_sending(
+ sietima => $s,
+ mails => [
+ object {
+ call sub { +{ shift->header_str_pairs } } => hash {
+ field 'List-Id' => 'test-list <sietima-test.list.example.com>';
+ field 'List-Owner' => '<mailto:admin@example.com>';
+ field 'List-Post' => '<mailto:sietima-test@list.example.com>';
+ field 'List-Test1' => '<mailto:someone@example.com>';
+ field 'List-Test-2' => 'http://test.example.com';
+
+ field 'Date' => D();
+ field 'MIME-Version' => D();
+ field 'Content-Type' => D();
+ field 'Content-Transfer-Encoding' => D();
+ field 'From' => 'someone@users.example.com';
+ field 'To' => 'sietima-test@list.example.com';
+ field 'Subject' => 'Test Message';
+
+ end;
+ };
+ },
+ ],
+ );
+};
+
+done_testing;