Bugzilla – Attachment 167209 Details for
Bug 36820
NEW_SUGGESTION is still sent for some modifications to the suggestion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36820: Adjust and add tests
Bug-36820-Adjust-and-add-tests.patch (text/plain), 3.52 KB, created by
Jonathan Druart
on 2024-05-28 10:29:34 UTC
(
hide
)
Description:
Bug 36820: Adjust and add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-05-28 10:29:34 UTC
Size:
3.52 KB
patch
obsolete
>From 08a4fca166c20b28871bdb04c891fb96c9d5903f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 28 May 2024 12:28:18 +0200 >Subject: [PATCH] Bug 36820: Adjust and add tests > >--- > t/db_dependent/Koha/Suggestions.t | 38 +++++++++++++++---------------- > 1 file changed, 18 insertions(+), 20 deletions(-) > >diff --git a/t/db_dependent/Koha/Suggestions.t b/t/db_dependent/Koha/Suggestions.t >index 1254248e43d..784aa7355de 100755 >--- a/t/db_dependent/Koha/Suggestions.t >+++ b/t/db_dependent/Koha/Suggestions.t >@@ -50,7 +50,7 @@ my $new_suggestion_2 = Koha::Suggestion->new( > )->store; > > subtest 'store' => sub { >- plan tests => 8; >+ plan tests => 9; > my $suggestion = Koha::Suggestion->new( > { suggestedby => $patron->{borrowernumber}, > biblionumber => $biblio_1->biblionumber, >@@ -69,37 +69,35 @@ subtest 'store' => sub { > > t::lib::Mocks::mock_preference( 'EmailPurchaseSuggestions', 0 ); > Koha::Notice::Messages->search->delete; >+ $suggestion->STATUS('REJECTED')->store; > $suggestion->STATUS('ASKED')->store; >- my $last_message = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->single; >- if ( !defined $last_message ) { >- $last_message = "No message was sent"; >- } >+ my $messages_sent = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } ); > is( >- $last_message, 'No message was sent', >+ $messages_sent->count, 1, > 'If EmailPurchaseSuggestions is not enabled, a message should not be sent' > ); > > t::lib::Mocks::mock_preference( 'EmailPurchaseSuggestions', 'EmailAddressForSuggestions' ); > Koha::Notice::Messages->search->delete; >+ $suggestion->STATUS('REJECTED')->store; > $suggestion->STATUS('ASKED')->store; >- $last_message = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->single; >- if ( !defined $last_message ) { >- fail('No message was sent'); >- } else { >- is( >- $last_message->letter_code, 'NEW_SUGGESTION', >- 'If EmailPurchaseSuggestions is enabled and the status of suggestion is set to ASKED, a message should be sent' >- ); >- } >+ $messages_sent = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } ); >+ is( $messages_sent->count, 1, 'If EmailPurchaseSuggestions is enabled and the status of suggestion is set to ASKED, a message should be sent' ); >+ is( >+ $messages_sent->next->letter_code, 'NEW_SUGGESTION', >+ 'If EmailPurchaseSuggestions is enabled and the status of suggestion is set to ASKED, a message should be sent' >+ ); >+ >+ Koha::Notice::Messages->search->delete; >+ $suggestion->set( { note => 'a note' } )->store; >+ $messages_sent = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } ); >+ is( $messages_sent->count, 1, 'NEW_SUGGESTION should not be sent again if status has not changed' ); > > Koha::Notice::Messages->search->delete; > $suggestion->STATUS('ACCEPTED')->store; >- $last_message = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->single; >- if ( !defined $last_message ) { >- $last_message = "No message was sent"; >- } >+ $messages_sent = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } ); > is( >- $last_message, 'No message was sent', >+ $messages_sent->count, 0, > 'If the status of suggestion is not set to ASKED, a message should not be sent' > ); > >-- >2.34.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 36820
: 167209 |
167210