Bug 40219: Add unit test to verify welcome email is not sent on validation failure
This test ensures that when extended attribute validation fails during patron creation via the API, no welcome email is sent. This validates the fix where extended_attributes() validation was moved before the welcome email is enqueued. Test plan: 1. Apply this patch 2. Run: prove t/db_dependent/api/v1/patrons.t 3. Verify all tests pass, including the new test that confirms no welcome email is sent when extended attribute validation fails Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
parent
328b77458f
commit
4d2f80925d
|
|
@ -581,7 +581,7 @@ subtest 'add() tests' => sub {
|
|||
|
||||
subtest 'extended_attributes handling tests' => sub {
|
||||
|
||||
plan tests => 25;
|
||||
plan tests => 29;
|
||||
|
||||
$mocked_patron->mock(
|
||||
'extended_attributes',
|
||||
|
|
@ -617,6 +617,23 @@ subtest 'add() tests' => sub {
|
|||
|
||||
is( Koha::Patrons->search->count, $patrons_count, 'No patron added' );
|
||||
|
||||
# Bug 40219: Test that welcome email is not sent when extended attribute validation fails
|
||||
t::lib::Mocks::mock_preference( 'AutoEmailNewUser', 1 );
|
||||
$letter_enqueued = 0;
|
||||
$extended_attrs_exception = 'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute';
|
||||
$t->post_ok(
|
||||
"//$userid:$password\@/api/v1/patrons" => json => {
|
||||
"firstname" => "Bug",
|
||||
"surname" => "FortyZeroTwoOneNine",
|
||||
"address" => "Somewhere",
|
||||
"category_id" => "ST",
|
||||
"city" => "TestCity",
|
||||
"library_id" => "MPL",
|
||||
"email" => 'bug40219@test.com'
|
||||
}
|
||||
)->status_is(400)->json_is( '/error' => "Missing mandatory extended attribute (type=$type)" );
|
||||
is( $letter_enqueued, 0, 'Bug 40219: No welcome email sent when extended attribute validation fails' );
|
||||
|
||||
$extended_attrs_exception = 'Koha::Exceptions::Patron::Attribute::InvalidType';
|
||||
$t->post_ok(
|
||||
"//$userid:$password@/api/v1/patrons" => json => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue