Bugzilla – Attachment 182413 Details for
Bug 35451
Add tablename field to additional_field_values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35451: (follow-up) Save join in C4::Serials::DelSubscription
Bug-35451-follow-up-Save-join-in-C4SerialsDelSubsc.patch (text/plain), 4.45 KB, created by
Martin Renvoize (ashimema)
on 2025-05-13 19:40:11 UTC
(
hide
)
Description:
Bug 35451: (follow-up) Save join in C4::Serials::DelSubscription
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-05-13 19:40:11 UTC
Size:
4.45 KB
patch
obsolete
>From c4d0a0df3b448b6bb8facb9eb855cb514c785655 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 13 May 2025 20:14:35 +0100 >Subject: [PATCH] Bug 35451: (follow-up) Save join in > C4::Serials::DelSubscription > >We can use the new record_table field to save ourselves a join in here >too. >--- > C4/Serials.pm | 5 +-- > t/db_dependent/Serials.t | 81 +++++++++++++++++++++++++++++++++++++++- > 2 files changed, 82 insertions(+), 4 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index d9bb117db10..ab80303d97d 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1842,10 +1842,9 @@ sub DelSubscription { > > Koha::AdditionalFieldValues->search( > { >- 'field.tablename' => 'subscription', >+ 'me.record_table' => 'subscription', > 'me.record_id' => $subscriptionid, >- }, >- { join => 'field' } >+ } > )->delete; > > logaction( "SERIAL", "DELETE", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog"); >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 1e2e5bbff69..0e71deea466 100755 >--- a/t/db_dependent/Serials.t >+++ b/t/db_dependent/Serials.t >@@ -19,7 +19,7 @@ use t::lib::Mocks; > use t::lib::TestBuilder; > use Test::MockModule; > use Test::NoWarnings; >-use Test::More tests => 64; >+use Test::More tests => 65; > > BEGIN { > use_ok( >@@ -738,6 +738,85 @@ subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { > > }; > >+subtest "DelSubscription" => sub { >+ plan tests => 5; >+ >+ # Create a mock for C4::Context preferences >+ t::lib::Mocks::mock_preference( "SubscriptionLog", 1 ); >+ >+ # Create a Subscription for testing >+ my $subscription_to_delete = NewSubscription( >+ undef, "", undef, undef, $budget_id, $biblionumber, >+ '2013-01-01', $frequency_id, undef, undef, undef, >+ undef, undef, undef, undef, undef, undef, >+ 1, $notes, undef, '2013-01-01', undef, $pattern_id, >+ undef, undef, 0, $internalnotes, 0, >+ undef, undef, 0, undef, '2013-12-31', 0 >+ ); >+ >+ # Verify subscription was created >+ my $subscription = GetSubscription($subscription_to_delete); >+ is( >+ $subscription->{subscriptionid}, $subscription_to_delete, >+ 'Subscription created successfully for deletion test' >+ ); >+ >+ # Create an additional field value for this subscription >+ my $additional_field = $builder->build_object( >+ { >+ class => 'Koha::AdditionalFields', >+ value => { >+ tablename => 'subscription', >+ name => 'test_field', >+ authorised_value_category => undef, >+ } >+ } >+ ); >+ >+ my $field_value = Koha::AdditionalFieldValue->new( >+ { >+ field_id => $additional_field->id, >+ record_id => $subscription_to_delete, >+ value => 'test_value', >+ record_table => 'subscription', >+ } >+ )->store; >+ >+ # Verify additional field value exists >+ my $count = Koha::AdditionalFieldValues->search( >+ { >+ 'me.record_table' => 'subscription', >+ 'me.record_id' => $subscription_to_delete, >+ } >+ )->count; >+ is( $count, 1, 'Additional field value was created for the subscription' ); >+ >+ my $action_logs_before = $schema->resultset('ActionLog')->search()->count; >+ >+ # Delete the subscription >+ DelSubscription($subscription_to_delete); >+ >+ # Test 1: Subscription should be deleted >+ $subscription = GetSubscription($subscription_to_delete); >+ is( $subscription, undef, 'Subscription was successfully deleted' ); >+ >+ # Test 2: Additional field values should be deleted >+ $count = Koha::AdditionalFieldValues->search( >+ { >+ 'me.record_table' => 'subscription', >+ 'me.record_id' => $subscription_to_delete, >+ } >+ )->count; >+ is( $count, 0, 'Additional field values were deleted with the subscription' ); >+ >+ # Test 3: Logaction should have been called with correct parameters >+ my $action_logs_after = $schema->resultset('ActionLog')->search()->count; >+ is( >+ $action_logs_after, $action_logs_before + 1, >+ 'logaction was called when SubscriptionLog preference is enabled' >+ ); >+}; >+ > subtest "_numeration" => sub { > > plan tests => 6; >-- >2.49.0
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 35451
:
159390
|
159391
|
159392
|
159393
|
159394
|
159747
|
159748
|
159749
|
159750
|
159751
|
173147
|
173148
|
173149
|
173150
|
173151
|
173421
|
173422
|
173423
|
173424
|
173425
|
178332
|
178333
|
178334
|
178335
|
178336
|
178337
|
178338
|
178339
|
178340
|
178341
|
180806
|
180807
|
180808
|
180809
|
180810
|
182401
|
182402
|
182403
|
182404
|
182405
|
182406
|
182407
|
182408
|
182409
|
182410
|
182411
|
182412
| 182413