From 7ca898a2ac3512baacd0e0864ce31531fc4f5bb9 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 10 Sep 2016 12:07:11 +0100 Subject: 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 --- t/tests/sietima/role/headers.t | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 t/tests/sietima/role/headers.t (limited to 't/tests') 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 '), + '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 '; + field 'List-Owner' => ''; + field 'List-Post' => ''; + field 'List-Test1' => ''; + 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; -- cgit v1.2.3