Bugzilla – Attachment 89195 Details for
Bug 5770
Email librarian when purchase suggestion made
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5770: (QA follow-up) Adapt for replyto handling
Bug-5770-QA-follow-up-Adapt-for-replyto-handling.patch (text/plain), 9.41 KB, created by
Martin Renvoize (ashimema)
on 2019-05-01 18:04:12 UTC
(
hide
)
Description:
Bug 5770: (QA follow-up) Adapt for replyto handling
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-05-01 18:04:12 UTC
Size:
9.41 KB
patch
obsolete
>From 6a71c80e860fc48f856510a448c5b57ed7103483 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 1 May 2019 18:58:23 +0100 >Subject: [PATCH] Bug 5770: (QA follow-up) Adapt for replyto handling > >The ReplyTo preferences allwo for libraries to setup various >combinations of addresses for email headers to ensure correct mail >delivery. This patch accounts for their configuration and use in the >suggestions notifications > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Suggestions.pm | 26 +++++-- > t/db_dependent/Suggestions.t | 131 ++++++++++++++++++++++++++--------- > 2 files changed, 118 insertions(+), 39 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 25328d0982..39faddde3f 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -471,12 +471,26 @@ sub NewSuggestion { > ) > ){ > >- my $toaddress = >- ( $emailpurchasesuggestions eq "BranchEmailAddress" ) >- ? ( Koha::Libraries->find( $full_suggestion->{branchcode} ) >- ->branchemail >- || C4::Context->preference('KohaAdminEmailAddress') ) >- : C4::Context->preference($emailpurchasesuggestions); >+ my $toaddress; >+ if ( $emailpurchasesuggestions eq "BranchEmailAddress" ) { >+ my $library = >+ Koha::Libraries->find( $full_suggestion->{branchcode} ); >+ $toaddress = >+ $library->branchreplyto >+ || $library->branchemail >+ || C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); >+ } >+ elsif ( $emailpurchasesuggestions eq "KohaAdminEmailAddress" ) { >+ $toaddress = C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); >+ } >+ else { >+ $toaddress = >+ C4::Context->preference($emailpurchasesuggestions) >+ || C4::Context->preference('ReplytoDefault') >+ || C4::Context->preference('KohaAdminEmailAddress'); >+ } > > C4::Letters::EnqueueLetter( > { >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 02d1d92bec..ab08771352 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -467,57 +467,122 @@ subtest 'DelSuggestionsOlderThan' => sub { > }; > > subtest 'EmailPurchaseSuggestions' => sub { >- plan tests => 6; >+ plan tests => 11; > > $dbh->do(q|DELETE FROM message_queue|); > >- Koha::Libraries->find('CPL')->update({ branchemail => 'branchemail@b.c' }); >- t::lib::Mocks::mock_preference( "KohaAdminEmailAddress", 'root@localhost'); >- t::lib::Mocks::mock_preference( "EmailAddressForSuggestions", 'a@b.c'); >+ t::lib::Mocks::mock_preference( "KohaAdminEmailAddress", >+ 'noreply@hosting.com' ); > >- # EmailAddressForSuggestions or BranchEmailAddress or KohaAdminEmailAddress or 0 >- t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "0"); >+ # EmailPurchaseSuggestions set to disabled >+ t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "0" ); > NewSuggestion($my_suggestion); >- my $newsuggestions_messages = C4::Letters::GetQueuedMessages({ >+ my $newsuggestions_messages = C4::Letters::GetQueuedMessages( >+ { > borrowernumber => $borrowernumber >- }); >- >- is( @$newsuggestions_messages, 0, 'NewSuggestions does not send an email when disabled' ); >+ } >+ ); >+ is( @$newsuggestions_messages, 0, >+ 'NewSuggestions does not send an email when disabled' ); >+ >+ # EmailPurchaseSuggestions set to BranchEmailAddress >+ t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", >+ "BranchEmailAddress" ); >+ NewSuggestion($my_suggestion); > >- t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "KohaAdminEmailAddress"); >+ t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); > NewSuggestion($my_suggestion); >- my $newsuggestions_messages = C4::Letters::GetQueuedMessages({ >- borrowernumber => $borrowernumber >- }); > >- is( @$newsuggestions_messages, 1, 'NewSuggestions sends an email' ); >- my $message1 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id}); >- is ($message1->{to_address}, 'root@localhost', 'to_address is KohaAdminEmailAddress'); >+ Koha::Libraries->find('CPL')->update( { branchemail => 'branchemail@hosting.com' } ); >+ NewSuggestion($my_suggestion); > >- t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "EmailAddressForSuggestions"); >+ Koha::Libraries->find('CPL')->update( { branchreplyto => 'branchemail@b.c' } ); > NewSuggestion($my_suggestion); >- $newsuggestions_messages = C4::Letters::GetQueuedMessages({ >+ >+ $newsuggestions_messages = C4::Letters::GetQueuedMessages( >+ { > borrowernumber => $borrowernumber >- }); >- my $message2 = C4::Letters::GetMessage( $newsuggestions_messages->[1]->{message_id}); >- is ($message2->{to_address}, 'a@b.c', 'to_address is EmailAddressForSuggestions'); >+ } >+ ); >+ isnt( @$newsuggestions_messages, 0, 'NewSuggestions sends an email' ); >+ my $message1 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); >+ is( $message1->{to_address}, 'noreply@hosting.com', >+'BranchEmailAddress falls back to KohaAdminEmailAddress if branchreplyto, branchemail and ReplytoDefault are not set' >+ ); >+ my $message2 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[1]->{message_id} ); >+ is( $message2->{to_address}, 'library@b.c', >+'BranchEmailAddress falls back to ReplytoDefault if neither branchreplyto or branchemail are set' >+ ); >+ my $message3 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[2]->{message_id} ); >+ is( $message3->{to_address}, 'branchemail@hosting.com', >+'BranchEmailAddress uses branchemail if branch_replto is not set' >+ ); >+ my $message4 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[3]->{message_id} ); >+ is( $message4->{to_address}, 'branchemail@b.c', >+'BranchEmailAddress uses branchreplyto in preference to branchemail when set' >+ ); >+ >+ # EmailPurchaseSuggestions set to KohaAdminEmailAddress >+ t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", >+ "KohaAdminEmailAddress" ); >+ >+ t::lib::Mocks::mock_preference( "ReplytoDefault", undef ); >+ NewSuggestion($my_suggestion); > >- t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "BranchEmailAddress"); >+ t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); > NewSuggestion($my_suggestion); >- $newsuggestions_messages = C4::Letters::GetQueuedMessages({ >+ >+ $newsuggestions_messages = C4::Letters::GetQueuedMessages( >+ { > borrowernumber => $borrowernumber >- }); >- my $message3 = C4::Letters::GetMessage( $newsuggestions_messages->[2]->{message_id}); >- is ($message3->{to_address}, 'branchemail@b.c', 'to_address is BranchEmailAddress'); >+ } >+ ); >+ my $message5 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[4]->{message_id} ); >+ is( $message5->{to_address}, >+ 'noreply@hosting.com', 'KohaAdminEmailAddress uses KohaAdminEmailAddress when ReplytoDefault is not set' ); >+ my $message6 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[5]->{message_id} ); >+ is( $message6->{to_address}, >+ 'library@b.c', 'KohaAdminEmailAddress uses ReplytoDefualt when ReplytoDefault is set' ); >+ >+ # EmailPurchaseSuggestions set to EmailAddressForSuggestions >+ t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", >+ "EmailAddressForSuggestions" ); >+ >+ t::lib::Mocks::mock_preference( "ReplytoDefault", undef ); >+ NewSuggestion($my_suggestion); > >- Koha::Libraries->find('CPL')->update({ branchemail => undef }); >+ t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); > NewSuggestion($my_suggestion); >- $newsuggestions_messages = C4::Letters::GetQueuedMessages({ >- borrowernumber => $borrowernumber >- }); >- my $message4 = C4::Letters::GetMessage( $newsuggestions_messages->[3]->{message_id}); >- isnt ($message4->{to_address}, 'branchemail@b.c', 'to_address is KohaAdminEmailAddress. Because branchemail is undef'); > >+ t::lib::Mocks::mock_preference( "EmailAddressForSuggestions", >+ 'suggestions@b.c' ); >+ NewSuggestion($my_suggestion); >+ >+ $newsuggestions_messages = C4::Letters::GetQueuedMessages( >+ { >+ borrowernumber => $borrowernumber >+ } >+ ); >+ my $message7 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[6]->{message_id} ); >+ is( $message7->{to_address}, >+ 'noreply@hosting.com', 'EmailAddressForSuggestions uses KohaAdminEmailAddress when neither EmailAddressForSuggestions or ReplytoDefault are set' ); >+ >+ my $message8 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[7]->{message_id} ); >+ is( $message8->{to_address}, >+ 'library@b.c', 'EmailAddressForSuggestions uses ReplytoDefault when EmailAddressForSuggestions is not set' ); >+ >+ my $message9 = >+ C4::Letters::GetMessage( $newsuggestions_messages->[8]->{message_id} ); >+ is( $message9->{to_address}, >+ 'suggestions@b.c', 'EmailAddressForSuggestions uses EmailAddressForSuggestions when set' ); > }; > > $schema->storage->txn_rollback; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5770
:
83384
|
83385
|
83386
|
83387
|
83388
|
83390
|
83615
|
83616
|
83617
|
84463
|
84812
|
89139
|
89140
|
89141
|
89142
|
89144
|
89145
|
89146
|
89147
|
89188
|
89189
|
89190
|
89191
|
89192
|
89193
|
89194
| 89195