Bugzilla – Attachment 91369 Details for
Bug 23272
Koha::AuthorisedValue should use Koha::Object::Limit::Library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23272: Adapt controller and tests
Bug-23272-Adapt-controller-and-tests.patch (text/plain), 5.42 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-07-05 19:26:33 UTC
(
hide
)
Description:
Bug 23272: Adapt controller and tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-07-05 19:26:33 UTC
Size:
5.42 KB
patch
obsolete
>From 1adc7217cb32bb9dcd0a4463ceb914a758e65d2f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 5 Jul 2019 16:24:17 -0300 >Subject: [PATCH] Bug 23272: Adapt controller and tests > >This patch adapts the controller script for handling authorised values, >and the tests to reflect the method names changes. > >To test: >- Verify you can add/delete/edit authorised values with/without branch >limitations, as usual >=> SUCCESS: All works as usual! >- Run: > $ kshell > k$ prove t/db_dependent/AuthorisedValues.t >=> SUCCESS: Tests pass! >- Sign off :-D >--- > admin/authorised_values.pl | 23 ++++++++++++----------- > t/db_dependent/AuthorisedValues.t | 12 ++++++------ > 2 files changed, 18 insertions(+), 17 deletions(-) > >diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl >index 4f951291e4..6080dbb640 100755 >--- a/admin/authorised_values.pl >+++ b/admin/authorised_values.pl >@@ -20,6 +20,8 @@ > use Modern::Perl; > > use CGI qw ( -utf8 ); >+use List::MoreUtils qw(any); >+ > use C4::Auth; > use C4::Context; > use C4::Koha; >@@ -49,22 +51,21 @@ our ($template, $borrowernumber, $cookie)= get_template_and_user({ > ################## ADD_FORM ################################## > # called by default. Used to create form to add or modify a record > if ($op eq 'add_form') { >- my ( $selected_branches, $category, $av ); >+ my ( @selected_branches, $category, $av ); > if ($id) { > $av = Koha::AuthorisedValues->new->find( $id ); >- $selected_branches = $av->branch_limitations; >+ @selected_branches = $av->library_limits->as_list; > } else { > $category = $input->param('category'); > } > >- my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; >+ my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } ); > my @branches_loop; >- foreach my $branch ( @$branches ) { >- my $selected = ( grep {$_ eq $branch->{branchcode}} @$selected_branches ) ? 1 : 0; >+ while ( my $branch = $branches->next ) { > push @branches_loop, { >- branchcode => $branch->{branchcode}, >- branchname => $branch->{branchname}, >- selected => $selected, >+ branchcode => $branch->branchcode, >+ branchname => $branch->branchname, >+ selected => any {$_->branchcode eq $branch->branchcode} @selected_branches, > }; > } > >@@ -126,7 +127,7 @@ if ($op eq 'add_form') { > $av->imageurl( $imageurl ); > eval{ > $av->store; >- $av->replace_branch_limitations( \@branches ); >+ $av->replace_library_limits( \@branches ); > }; > if ( $@ ) { > push @messages, {type => 'error', code => 'error_on_update' }; >@@ -145,7 +146,7 @@ if ($op eq 'add_form') { > > eval { > $av->store; >- $av->replace_branch_limitations( \@branches ); >+ $av->replace_library_limits( \@branches ); > }; > > if ( $@ ) { >@@ -230,7 +231,7 @@ if ( $op eq 'list' ) { > $row_data{lib} = $av->lib; > $row_data{lib_opac} = $av->lib_opac; > $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $av->imageurl ); >- $row_data{branches} = $av->branch_limitations; >+ $row_data{branches} = $av->library_limits->as_list; > $row_data{id} = $av->id; > push(@loop_data, \%row_data); > } >diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t >index f7da7a5f77..d16d282731 100644 >--- a/t/db_dependent/AuthorisedValues.t >+++ b/t/db_dependent/AuthorisedValues.t >@@ -95,7 +95,7 @@ is( @authorised_values, 3, "Get correct number of values" ); > my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode}; > my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode}; > >-$av1->add_branch_limitation( $branchcode1 ); >+$av1->add_library_limit( $branchcode1 ); > > @authorised_values = Koha::AuthorisedValues->new()->search( { category => 'av_for_testing', branchcode => $branchcode1 } ); > is( @authorised_values, 3, "Search including value with a branch limit ( branch can use the limited value ) gives correct number of results" ); >@@ -103,15 +103,15 @@ is( @authorised_values, 3, "Search including value with a branch limit ( branch > @authorised_values = Koha::AuthorisedValues->new()->search( { category => 'av_for_testing', branchcode => $branchcode2 } ); > is( @authorised_values, 2, "Search including value with a branch limit ( branch *cannot* use the limited value ) gives correct number of results" ); > >-$av1->del_branch_limitation( $branchcode1 ); >+$av1->del_library_limit( $branchcode1 ); > @authorised_values = Koha::AuthorisedValues->new()->search( { category => 'av_for_testing', branchcode => $branchcode2 } ); > is( @authorised_values, 3, "Branch limitation deleted successfully" ); > >-$av1->add_branch_limitation( $branchcode1 ); >-$av1->branch_limitations( [ $branchcode1, $branchcode2 ] ); >+$av1->add_library_limit( $branchcode1 ); >+$av1->library_limits( [ $branchcode1, $branchcode2 ] ); > >-my $limits = $av1->branch_limitations; >-is( @$limits, 2, 'branch_limitations functions correctly both as setter and getter' ); >+my $limits = $av1->library_limits->as_list; >+is( @$limits, 2, 'library_limits functions correctly both as setter and getter' ); > > my @categories = Koha::AuthorisedValues->new->categories; > is( @categories, 3, 'There should have 2 categories inserted' ); >-- >2.22.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 23272
:
91368
|
91369
|
91462
|
91463
|
92768
|
92769
|
92775
|
93197